Search Results

Search found 71 results on 3 pages for 'gridviewcolumn'.

Page 1/3 | 1 2 3  | Next Page >

  • WPF ListView get GridViewColumn from control inside DataTemplate

    - by ragi
    Example: <ListView Name="lvAnyList" ItemsSource="{Binding}"> <ListView.View> <GridView> <GridViewColumn Header="xx" DisplayMemberBinding="{Binding XX}" CellTemplate="{DynamicResource MyDataTemplate}"/> <GridViewColumn Header="yy"> <GridViewColumn.CellTemplate> <DataTemplate> <TextBlock Text="{Binding YY}" /> </DataTemplate> </GridViewColumn.CellTemplate> </GridViewColumn> </GridView> </ListView.View> </ListView> If I access the TextBlock inside DataTemplate I will have access to information about the bound path. But I don't know how to find (starting from the TextBlock) its containing GridViewColumn (which is in the GridViewRowPresenter columns list) and compare it to the grid's GridViewColumn (from GridViewHeaderRowPresenter column list) to get the header's name. At the end I should have the pairs: xx-XX, yy-YY I can find a list of all TextBlocks inside ListView by using this: GridViewRowPresenter gvrp = ControlAux.GetVisualDescendants<GridViewRowPresenter>(element).FirstOrDefault(); IEnumerable<TextBlock> entb = GetVisualDescendants<TextBlock>(gvrp); I can find a list of all GridViewColumnHeaders: GridViewHeaderRowPresenter gvhrp = ControlAux.GetVisualDescendants<GridViewHeaderRowPresenter>(element).FirstOrDefault(); And I cannot find the connection between the TextBlocks and the GridViewColumns... I hope this is understandable.

    Read the article

  • Content alignment for Gridviewcolumn in the listview

    - by Pankaj Upadhyay
    Please see the picture below Following is the code for this :: <Grid> <ListView Style="{StaticResource listViewStyle}" Name="transactionListView" HorizontalAlignment="Stretch" VerticalAlignment="Top" ItemsSource="{Binding}" MouseDoubleClick="transactionListView_MouseDoubleClick" IsSynchronizedWithCurrentItem="True" > <ListView.View> <GridView ColumnHeaderContainerStyle="{StaticResource gridViewHeaderColumnStyle}"> <GridView.Columns> <GridViewColumn Width="70" Header="Serial" DisplayMemberBinding="{Binding Path=Serial}" /> <GridViewColumn Width="100" Header="Date" DisplayMemberBinding="{Binding Path=Date, StringFormat={}{0:dd-MM-yyyy}}" /> <GridViewColumn Width="200" Header="Seller" DisplayMemberBinding="{Binding Path=Seller}" /> <GridViewColumn Width="200" Header="Buyer" DisplayMemberBinding="{Binding Path=Buyer}" /> <GridViewColumn Width="70" Header="Bales" DisplayMemberBinding="{Binding Path=Bales}" /> </GridView.Columns> </GridView> </ListView.View> </ListView> </Grid>

    Read the article

  • WPF Control Background under GridViewColumn

    - by sergo_lsn
    Hi, I'd like make background for colums like in this image http://www.freeimagehosting.net/image.php?e2435df982.png I have CheckBoxes on the left and TreeView on the right. In one column I have checkboxes in other I have treeview. In column with checkboxes I need set background. Background has to be permanent. .... </DataTemplate> </GridViewColumn.CellTemplate> </GridViewColumn> <GridViewColumn Width="25"> All column has to have background not only cell <GridViewColumn.CellTemplate> <DataTemplate> <CheckBox> <CheckBox.Resources> <ResourceDictionary> <ResourceDictionary.MergedDictionaries> .... </ResourceDictionary.MergedDictionaries> </ResourceDictionary> </CheckBox.Resources> </CheckBox> </DataTemplate> </GridViewColumn.CellTemplate> </GridViewColumn> </GridViewColumn> <GridViewColumn Width="300"/> </TreeListView.Columns> <TreeListView.Resources> <ResourceDictionary> <ResourceDictionary.MergedDictionaries> ... TreeView.xaml </ResourceDictionary.MergedDictionaries> </ResourceDictionary> </TreeListView.Resources> <TreeListView.ItemTemplate> <HierarchicalDataTemplate> <HierarchicalDataTemplate.ItemsSource> .... </HierarchicalDataTemplate.ItemsSource> </HierarchicalDataTemplate> </TreeListView.ItemTemplate> </TreeListView>

    Read the article

  • WPF - Centering a checkbox in a GridViewColumn?

    - by Sonny Boy
    Hey all, I'm currently struggling on getting my checkboxes to property center within my GridViewColumns. I've defined a style for my checkboxes like so: <Style TargetType="{x:Type CheckBox}" x:Key="DataGridCheckBox"> <Setter Property="HorizontalAlignment" Value="Center" /> <Setter Property="HorizontalContentAlignment" Value="Center" /> <Setter Property="IsEnabled" Value="False" /> <Setter Property="Margin" Value="4" /> <Setter Property="VerticalAlignment" Value="Center" /> <Setter Property="VerticalContentAlignment" Value="Center" /> <Setter Property="Width" Value="{Binding RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type GridViewColumn}},Path=ActualWidth}" /> </Style> And my checkboxes are added into the GridViewColumn using a DataTemplate like this: <GridViewColumn Header="Comment"> <GridViewColumn.CellTemplate> <DataTemplate> <CheckBox Style="{StaticResource DataGridCheckBox}" IsChecked="{Binding PropertyItem.Comment, Converter={StaticResource booleanConverter}, ConverterParameter='string'}"/> </DataTemplate> </GridViewColumn.CellTemplate> </GridViewColumn> But the problem I have is that the checkboxes remain left-aligned (even when resizing the column). Any ideas? Thanks in advance, Sonny

    Read the article

  • Horrorble performance using ListViews with nested objects in WPF

    - by Christian
    Hi community, like mentioned in the title I get a horrible performance if I use ListViews with nested objects. My scenario is: Each row of a ListView presents an object of the class Transaction with following attributes: private int mTransactionID; private IBTTransactionSender mSender; private IBTTransactionReceiver mReceiver; private BTSubstrate mSubstrate; private double mAmount; private string mDeliveryNote; private string mNote; private DateTime mTransactionDate; private DateTime mCreationTimestamp; private BTEmployee mEmployee; private bool mImported; private bool mDescendedFromRecurringTransaction; Each attribute can be accessed by its corresponding property. An ObservableCollection<Transaction> is bound to the ItemsSource of a ListView. The ListView itself looks like the following: </ListView.GroupStyle> <ListView.View> <GridView> <GridViewColumn core:SortableListView.SortPropertyName="Transaction.ToSave" Width="80"> <GridViewColumnHeader Name="GVCHLoadedToSave" Style="{StaticResource ListViewHeaderStyle}">Speichern</GridViewColumnHeader> <GridViewColumn.CellTemplate> <DataTemplate> <Grid> <CheckBox Name="CBListViewItem" IsChecked="{Binding Path=Transaction.ToSave, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"></CheckBox> </Grid> </DataTemplate> </GridViewColumn.CellTemplate> </GridViewColumn> <GridViewColumn core:SortableListView.SortPropertyName="Transaction.TransactionDate" Width="80"> <GridViewColumnHeader Name="GVCHLoadedDate" Style="{StaticResource ListViewHeaderStyle}">Datum</GridViewColumnHeader> <GridViewColumn.CellTemplate> <DataTemplate> <Grid> <TextBlock Text="{Binding ElementName=DPDate, Path=Text}" Style="{StaticResource GridBlockStyle}"/> <toolkit:DatePicker Name="DPDate" Width="{Binding ElementName=GVCHDate, Path=ActualWidth}" SelectedDateFormat="Short" Style="{StaticResource GridEditStyle}" SelectedDate="{Binding Path=Transaction.TransactionDate, Mode=TwoWay}" SelectedDateChanged="DPDate_SelectedDateChanged"/> </Grid> </DataTemplate> </GridViewColumn.CellTemplate> </GridViewColumn> <GridViewColumn core:SortableListView.SortPropertyName="Transaction.Sender.Description" Width="120"> <GridViewColumnHeader Name="GVCHLoadedSender" Style="{StaticResource ListViewHeaderStyle}">Von</GridViewColumnHeader> <GridViewColumn.CellTemplate> <DataTemplate> <Grid> <TextBlock Text="{Binding Path=Transaction.Sender.Description}" Style="{StaticResource GridBlockStyle}"/> <ComboBox Name="CBSender" Width="{Binding ElementName=GVCHSender, Path=ActualWidth}" SelectedItem="{Binding Path=Transaction.Sender}" DisplayMemberPath="Description" Text="{Binding Path=Sender.Description, Mode=OneWay}" ItemsSource="{Binding ElementName=Transaction, Path=SenderList}" Style="{StaticResource GridEditStyle}"> </ComboBox> </Grid> </DataTemplate> </GridViewColumn.CellTemplate> </GridViewColumn> <GridViewColumn core:SortableListView.SortPropertyName="Transaction.Receiver.Description" Width="120"> <GridViewColumnHeader Name="GVCHLoadedReceiver" Style="{StaticResource ListViewHeaderStyle}">Nach</GridViewColumnHeader> <GridViewColumn.CellTemplate> <DataTemplate> <Grid> <TextBlock Text="{Binding Path=Transaction.Receiver.Description}" Style="{StaticResource GridBlockStyle}"/> <ComboBox Name="CBReceiver" Width="{Binding ElementName=GVCHReceiver, Path=ActualWidth}" SelectedItem="{Binding Path=Transaction.Receiver}" DisplayMemberPath="Description" Text="{Binding Path=Receiver.Description, Mode=OneWay}" ItemsSource="{Binding ElementName=Transaction, Path=ReceiverList}" Style="{StaticResource GridEditStyle}"> </ComboBox> </Grid> </DataTemplate> </GridViewColumn.CellTemplate> </GridViewColumn> <GridViewColumn core:SortableListView.SortPropertyName="Transaction.Substrate.Description" Width="140"> <GridViewColumnHeader Name="GVCHLoadedSubstrate" Style="{StaticResource ListViewHeaderStyle}">Substrat</GridViewColumnHeader> <GridViewColumn.CellTemplate> <DataTemplate> <Grid> <TextBlock Text="{Binding Path=Transaction.Substrate.Description}" Style="{StaticResource GridBlockStyle}"/> <ComboBox Name="CBSubstrate" Width="{Binding ElementName=GVCHSubstrate, Path=ActualWidth}" SelectedItem="{Binding Path=Transaction.Substrate}" DisplayMemberPath="Description" Text="{Binding Path=Substrate.Description, Mode=OneWay}" ItemsSource="{Binding ElementName=Transaction, Path=SubstrateList}" Style="{StaticResource GridEditStyle}"> </ComboBox> </Grid> </DataTemplate> </GridViewColumn.CellTemplate> </GridViewColumn> <GridViewColumn core:SortableListView.SortPropertyName="Transaction.Amount" Width="80"> <GridViewColumnHeader Name="GVCHLoadedAmount" Style="{StaticResource ListViewHeaderStyle}">Menge [kg]</GridViewColumnHeader> <GridViewColumn.CellTemplate> <DataTemplate> <Grid> <TextBlock Text="{Binding Path=Transaction.Amount}" Style="{StaticResource GridBlockStyle}"/> <TextBox Name="TBAmount" Text="{Binding Path=Transaction.Amount, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Width="{Binding ElementName=GVCHAmount, Path=ActualWidth}" Style="{StaticResource GridTextBoxStyle}" /> </Grid> </DataTemplate> </GridViewColumn.CellTemplate> </GridViewColumn> <GridViewColumn core:SortableListView.SortPropertyName="Transaction.DeliveryNote" Width="100"> <GridViewColumnHeader Name="GVCHLoadedDeliveryNote" Style="{StaticResource ListViewHeaderStyle}">Lieferschein Nr.</GridViewColumnHeader> <GridViewColumn.CellTemplate> <DataTemplate> <Grid> <TextBlock Text="{Binding Path=Transaction.DeliveryNote}" Style="{StaticResource GridBlockStyle}"/> <TextBox Name="TBDeliveryNote" Text="{Binding Path=Transaction.DeliveryNote, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Width="{Binding ElementName=GVCHDeliveryNote, Path=ActualWidth}" Style="{StaticResource GridEditStyle}" /> </Grid> </DataTemplate> </GridViewColumn.CellTemplate> </GridViewColumn> <GridViewColumn core:SortableListView.SortPropertyName="Transaction.Note" Width="190"> <GridViewColumnHeader Name="GVCHLoadedNote" Style="{StaticResource ListViewHeaderStyle}">Bemerkung</GridViewColumnHeader> <GridViewColumn.CellTemplate> <DataTemplate> <Grid> <TextBlock Text="{Binding Path=Transaction.Note}" Style="{StaticResource GridBlockStyle}"/> <TextBox Name="TBNote" Text="{Binding Path=Transaction.Note, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Width="{Binding ElementName=GVCHNote, Path=ActualWidth}" Style="{StaticResource GridEditStyle}" /> </Grid> </DataTemplate> </GridViewColumn.CellTemplate> </GridViewColumn> <GridViewColumn core:SortableListView.SortPropertyName="Transaction.Employee.LastName" Width="100"> <GridViewColumnHeader Name="GVCHLoadedEmployee" Style="{StaticResource ListViewHeaderStyle}">Mitarbeiter</GridViewColumnHeader> <GridViewColumn.CellTemplate> <DataTemplate> <Grid> <TextBlock Text="{Binding Path=Transaction.Employee.LastName}" Style="{StaticResource GridBlockStyle}"/> <ComboBox Name="CBEmployee" Width="{Binding ElementName=GVCHEmployee, Path=ActualWidth}" SelectedItem="{Binding Path=Transaction.Employee}" DisplayMemberPath="LastName" Text="{Binding Path=Employee.LastName, Mode=OneWay}" ItemsSource="{Binding ElementName=Transaction, Path=EmployeeList}" Style="{StaticResource GridEditStyle}"> </ComboBox> </Grid> </DataTemplate> </GridViewColumn.CellTemplate> </GridViewColumn> </GridView> </ListView.View> </ListView> As you can see in the screenshot the user got the possibility to change the values of the transaction attributes with comboboxes. Ok now to my problem. If I click on the "Laden" button the application will load about 150 entries in the ObservableCollection<Transaction>. Before I fill the collection I set the ItemsSource of the ListView to null and after filling I bind the collection to the ItemsSource once again. The loading itself takes a few milliseconds, but the rendering of the filled collection takes a long time (150 entries = about 20 sec). I tested to delete all Comboboxes out of the xaml and i got a better performance, because I don't have to fill the ComboBoxes for each row. But I need to have these comboboxes for modifing the attributes of the Transaction. Does anybody know how to improve the performance? THX

    Read the article

  • C# WPF XAML Problem with icon in GridViewColumn

    - by Alex
    I've created a ListView with a GridView component in it. Now trying to fill one of the cells with an icon (PNG) like in the code sample below (save_icon.png): <ListView.View> <GridView> <GridViewColumn Header="Date" Width="Auto" DisplayMemberBinding="{Binding Date}" /> <GridViewColumn Header="Time" Width="Auto" DisplayMemberBinding="{Binding Time}" /> <GridViewColumn Header="FriendlyName" Width="Auto" DisplayMemberBinding="{Binding FriendlyName}" /> <GridViewColumn Width="Auto"> <Image Source="save_icon.png" /> </GridViewColumn> </GridView> </ListView.View> Visual Studio gives me an error on the line, where i put the icon into the column (ERROR: "Error 35: The file save_icon.png is not part of the project or its 'Build Action' property is not set to 'Resource'.") I added the icon to the project as a resource and when i start the app, everything works (the icon appears at the right place). But the WPF designer window can't be reloaded and i'm not able to see changes in the designer, when i change the XAML code. Can somebody explain this error or am i doing something wrong? Thanks for every hint in advance!

    Read the article

  • GridViewColumn not subscribing to PropertyChanged event in a ListView

    - by Chris Wenham
    I have a ListView with a GridView that's bound to the properties of a class that implements INotifyPropertyChanged, like this: <ListView Name="SubscriptionView" Grid.Column="0" Grid.ColumnSpan="2" Grid.Row="2" ItemsSource="{Binding Path=Subscriptions}"> <ListView.View> <GridView> <GridViewColumn Width="24" CellTemplate="{StaticResource IncludeSubscriptionTemplate}"/> <GridViewColumn Width="150" DisplayMemberBinding="{Binding Path=Name}" Header="Subscription"/> <GridViewColumn Width="75" DisplayMemberBinding="{Binding Path=RecordsWritten}" Header="Records"/> <GridViewColumn Width="Auto" CellTemplate="{StaticResource FilenameTemplate}"/> </GridView> </ListView.View> </ListView> The class looks like this: public class Subscription : INotifyPropertyChanged { public int RecordsWritten { get { return _records; } set { _records = value; if (PropertyChanged != null) PropertyChanged(this, new PropertyChangedEventArgs("RecordsWritten")); } } private int _records; ... } So I fire up a BackgroundWorker and start writing records, updating the RecordsWritten property and expecting the value to change in the UI, but it doesn't. In fact, the value of PropertyChanged on the Subscription objects is null. This is a puzzler, because I thought WPF is supposed to subscribe to the PropertyChanged event of data objects that implement INotifyPropertyChanged. Am I doing something wrong here?

    Read the article

  • WPF ListView GridViewColumn Double Click

    - by Kevin
    Hi, I have a WPF ListView that opens a certain window when double clicked on a certain item inside the list view, but I have a problem. When I double click the GridViewColumn, that also opens up a certain window. Is there a way to detect if the sender is a gridviewColumn or a listView item? Thanks

    Read the article

  • Binding using ElementName for a control within the Grid\ListView

    - by i2nfo
    Hi I am currently busy with a WPF application that uses a "GridView". There are several template columns one of which is a ComboBox in column 3 named cmbInputControlType. What I would like to do using my Converter class, which I have already created, is binding the visibility of the TextBox(txtFrom) in column 4 to the selected value of the ComboBox(Column 3). Basically if you select a value from the the ComboBox(cmbInputControlType - column 3), it must update teh visibility of the TextBox(txtFrom - column 4) <ListView Height="150" ScrollViewer.HorizontalScrollBarVisibility="Auto" ScrollViewer.VerticalScrollBarVisibility="Auto" Width="435" HorizontalAlignment="Center" Margin="5,0,5,5" Name="lstInput" VerticalAlignment="Top" SelectionMode="Single" HorizontalContentAlignment="Left"> <ListView.Resources> <local:InputControlTypeConverter x:Key="InputConType" /> </ListView.Resources> <ListView.View> <GridView> <!--Column 1--> <GridViewColumn Header="ParameterName" x:Name="lblParameterName" DisplayMemberBinding="{Binding ParameterName}" Width="100" /> <!--Column 2--> <GridViewColumn Header="DisplayName"> <GridViewColumn.CellTemplate> <DataTemplate> <TextBox x:Name="txtDisplayName" Width="150" /> </DataTemplate> </GridViewColumn.CellTemplate> </GridViewColumn> <!--Column 3--> <GridViewColumn Header="ControlType"> <GridViewColumn.CellTemplate> <DataTemplate> <ComboBox x:Name="cmbInputControlType" Width="100" SelectionChanged="cmbInputControlType_SelectionChanged" > <ComboBoxItem Content="TextBox" /> <ComboBoxItem Content="Copy" /> </ComboBox> </DataTemplate> </GridViewColumn.CellTemplate> </GridViewColumn> <!--Column 4--> <GridViewColumn Header="From"> <GridViewColumn.CellTemplate> <DataTemplate> <TextBox x:Name="txtCopyFrom" Width="150" Visibility="{Binding ElementName=cmbInputControlType,Path=SelectedItem, Converter={StaticResource InputConType}}" /> </DataTemplate> </GridViewColumn.CellTemplate> </GridViewColumn> <!--Column 5--> <GridViewColumn Header="To"> <GridViewColumn.CellTemplate> <DataTemplate> <TextBox x:Name="txtCopyTo" Width="150" /> </DataTemplate> </GridViewColumn.CellTemplate> </GridViewColumn> </GridView> </ListView.View> </ListView>

    Read the article

  • Using a WPF ListView as a DataGrid

    - by psheriff
    Many people like to view data in a grid format of rows and columns. WPF did not come with a data grid control that automatically creates rows and columns for you based on the object you pass it. However, the WPF Toolkit can be downloaded from CodePlex.com that does contain a DataGrid control. This DataGrid gives you the ability to pass it a DataTable or a Collection class and it will automatically figure out the columns or properties and create all the columns for you and display the data.The DataGrid control also supports editing and many other features that you might not always need. This means that the DataGrid does take a little more time to render the data. If you want to just display data (see Figure 1) in a grid format, then a ListView works quite well for this task. Of course, you will need to create the columns for the ListView, but with just a little generic code, you can create the columns on the fly just like the WPF Toolkit’s DataGrid. Figure 1: A List of Data using a ListView A Simple ListView ControlThe XAML below is what you would use to create the ListView shown in Figure 1. However, the problem with using XAML is you have to pre-define the columns. You cannot re-use this ListView except for “Product” data. <ListView x:Name="lstData"          ItemsSource="{Binding}">  <ListView.View>    <GridView>      <GridViewColumn Header="Product ID"                      Width="Auto"               DisplayMemberBinding="{Binding Path=ProductId}" />      <GridViewColumn Header="Product Name"                      Width="Auto"               DisplayMemberBinding="{Binding Path=ProductName}" />      <GridViewColumn Header="Price"                      Width="Auto"               DisplayMemberBinding="{Binding Path=Price}" />    </GridView>  </ListView.View></ListView> So, instead of creating the GridViewColumn’s in XAML, let’s learn to create them in code to create any amount of columns in a ListView. Create GridViewColumn’s From Data TableTo display multiple columns in a ListView control you need to set its View property to a GridView collection object. You add GridViewColumn objects to the GridView collection and assign the GridView to the View property. Each GridViewColumn object needs to be bound to a column or property name of the object that the ListView will be bound to. An ADO.NET DataTable object contains a collection of columns, and these columns have a ColumnName property which you use to bind to the GridViewColumn objects. Listing 1 shows a sample of reading and XML file into a DataSet object. After reading the data a GridView object is created. You can then loop through the DataTable columns collection and create a GridViewColumn object for each column in the DataTable. Notice the DisplayMemberBinding property is set to a new Binding to the ColumnName in the DataTable. C#private void FirstSample(){  // Read the data  DataSet ds = new DataSet();  ds.ReadXml(GetCurrentDirectory() + @"\Xml\Product.xml");    // Create the GridView  GridView gv = new GridView();   // Create the GridView Columns  foreach (DataColumn item in ds.Tables[0].Columns)  {    GridViewColumn gvc = new GridViewColumn();    gvc.DisplayMemberBinding = new Binding(item.ColumnName);    gvc.Header = item.ColumnName;    gvc.Width = Double.NaN;    gv.Columns.Add(gvc);  }   // Setup the GridView Columns  lstData.View = gv;  // Display the Data  lstData.DataContext = ds.Tables[0];} VB.NETPrivate Sub FirstSample()  ' Read the data  Dim ds As New DataSet()  ds.ReadXml(GetCurrentDirectory() & "\Xml\Product.xml")   ' Create the GridView  Dim gv As New GridView()   ' Create the GridView Columns  For Each item As DataColumn In ds.Tables(0).Columns    Dim gvc As New GridViewColumn()    gvc.DisplayMemberBinding = New Binding(item.ColumnName)    gvc.Header = item.ColumnName    gvc.Width = [Double].NaN    gv.Columns.Add(gvc)  Next   ' Setup the GridView Columns  lstData.View = gv  ' Display the Data  lstData.DataContext = ds.Tables(0)End SubListing 1: Loop through the DataTable columns collection to create GridViewColumn objects A Generic Method for Creating a GridViewInstead of having to write the code shown in Listing 1 for each ListView you wish to create, you can create a generic method that given any DataTable will return a GridView column collection. Listing 2 shows how you can simplify the code in Listing 1 by setting up a class called WPFListViewCommon and create a method called CreateGridViewColumns that returns your GridView. C#private void DataTableSample(){  // Read the data  DataSet ds = new DataSet();  ds.ReadXml(GetCurrentDirectory() + @"\Xml\Product.xml");   // Setup the GridView Columns  lstData.View =      WPFListViewCommon.CreateGridViewColumns(ds.Tables[0]);  lstData.DataContext = ds.Tables[0];} VB.NETPrivate Sub DataTableSample()  ' Read the data  Dim ds As New DataSet()  ds.ReadXml(GetCurrentDirectory() & "\Xml\Product.xml")   ' Setup the GridView Columns  lstData.View = _      WPFListViewCommon.CreateGridViewColumns(ds.Tables(0))  lstData.DataContext = ds.Tables(0)End SubListing 2: Call a generic method to create GridViewColumns. The CreateGridViewColumns MethodThe CreateGridViewColumns method will take a DataTable as a parameter and create a GridView object with a GridViewColumn object in its collection for each column in your DataTable. C#public static GridView CreateGridViewColumns(DataTable dt){  // Create the GridView  GridView gv = new GridView();  gv.AllowsColumnReorder = true;   // Create the GridView Columns  foreach (DataColumn item in dt.Columns)  {    GridViewColumn gvc = new GridViewColumn();    gvc.DisplayMemberBinding = new Binding(item.ColumnName);    gvc.Header = item.ColumnName;    gvc.Width = Double.NaN;    gv.Columns.Add(gvc);  }   return gv;} VB.NETPublic Shared Function CreateGridViewColumns _  (ByVal dt As DataTable) As GridView  ' Create the GridView  Dim gv As New GridView()  gv.AllowsColumnReorder = True   ' Create the GridView Columns  For Each item As DataColumn In dt.Columns    Dim gvc As New GridViewColumn()    gvc.DisplayMemberBinding = New Binding(item.ColumnName)    gvc.Header = item.ColumnName    gvc.Width = [Double].NaN    gv.Columns.Add(gvc)  Next   Return gvEnd FunctionListing 3: The CreateGridViewColumns method takes a DataTable and creates GridViewColumn objects in a GridView. By separating this method out into a class you can call this method anytime you want to create a ListView with a collection of columns from a DataTable. SummaryIn this blog you learned how to create a ListView that acts like a DataGrid. You are able to use a DataTable as both the source of the data, and for creating the columns for the ListView. In the next blog entry you will learn how to use the same technique, but for Collection classes. NOTE: You can download the complete sample code (in both VB and C#) at my website. http://www.pdsa.com/downloads. Choose Tips & Tricks, then "WPF ListView as a DataGrid" from the drop-down. Good Luck with your Coding,Paul Sheriff ** SPECIAL OFFER FOR MY BLOG READERS **Visit http://www.pdsa.com/Event/Blog for a free eBook on "Fundamentals of N-Tier".

    Read the article

  • WPF MVVM: how to bind GridViewColumn to ViewModel-Collection?

    - by Sam
    In my View I got a ListView bound to a CollectionView in my ViewModel, for example like this: <ListView ItemsSource="{Binding MyCollection}" IsSynchronizedWithCurrentItem="true"> <ListView.View> <GridView> <GridViewColumn Header="Title" DisplayMemberBinding="{Binding Path=Title}"/> <GridViewColumn Header="Name" DisplayMemberBinding="{Binding Path=Name}"/> <GridViewColumn Header="Phone" DisplayMemberBinding="{Binding Path=Phone}"/> <GridViewColumn Header="E-mail" DisplayMemberBinding="{Binding Path=EMail}"/> </GridView> </ListView.View> </ListView> Right now these GridViewColumns are fixed, but I'd like to be able to change them from the ViewModel. I'd guess I'll have to bind the GridViewColumn-collection to something in the ViewModel, but what, and how? The ViewModel does know nothing of WPF, so I got no clue how to achieve this in MVVM. any help here?

    Read the article

  • WPF Check/Uncheck all checkboxes located in a gridview

    - by toni
    Hi! I have a gridview with some columns. One of these columns is checkbox type. Then I have two buttons in my UI, one for check all and another for uncheck all. I would like to check all checkboxes in the column when I press the a button and uncheck all checkboxes when I press the another one. How can I do this? Some snippet code: <... <Classes:SortableListView x:Name="lstViewRutas" ItemsSource="{Binding Source={StaticResource RutasCollectionData}}" ... > <...> <GridViewColumn Header="Activa" Width="50"> <GridViewColumn.CellTemplate> <DataTemplate> <CheckBox x:Name="chkBxF" Click="chkBx_Click" IsChecked="{Binding Path=Activa}" HorizontalContentAlignment="Stretch" HorizontalAlignment="Stretch"/> </DataTemplate> </GridViewColumn.CellTemplate> </GridViewColumn> <...> </Classes:SortableListView> <...> </Page> My data object binding to gridview is: namespace GParts.Classes { public class RutasCollection { /// <summary> /// Colección de datos de la tabla /// </summary> ObservableCollection<RutasData> _RutasCollection; /// <summary> /// Constructor. Crea una nueva instancia tipo ObservableCollection /// de tipo RutasData /// </summary> public RutasCollection() { _RutasCollection = new ObservableCollection<RutasData>(); } /// <summary> /// Retorna el conjunto entero de rutas en la colección /// </summary> public ObservableCollection<RutasData> Get { get { return _RutasCollection; } } /// <summary> /// Retorna el conjunto entero de rutas en la colección /// </summary> /// <returns></returns> public ObservableCollection<RutasData> GetCollection() { return _RutasCollection; } /// <summary> /// Añade un elemento tipo RutasData a la colección /// </summary> /// <param name="hora"></param> public void Add(RutasData ruta) { _RutasCollection.Add(ruta); } /// <summary> /// Elimina un elemento tipo RutasData de la colección /// </summary> /// <param name="ruta"></param> public void Remove(RutasData ruta) { _RutasCollection.Remove(ruta); } /// <summary> /// Elimina todos los registros de la colección /// </summary> public void RemoveAll() { _RutasCollection.Clear(); } /// <summary> /// Inserta un elemento tipo RutasData a la colección /// en la posición rowId establecida /// </summary> /// <param name="rowId"></param> /// <param name="ruta"></param> public void Insert(int rowId, RutasData ruta) { _RutasCollection.Insert(rowId, ruta); } } /// <summary> /// Clase RutasData /// </summary> // Registro tabla interficie pantalla public class RutasData { public int Id { get; set; } public bool Activa { get; set; } public string Ruta { get; set; } } } and in my page loaded event I do this to populate gridview: // Obtiene datos tabla Rutas var tbl_Rutas = Accessor.GetRutasTable(); // This method returns entire table foreach (var ruta in tbl_Rutas) { _RutasCollection.Add(new RutasData { Id = (int) ruta.Id, Ruta = ruta.Ruta, Activa = (bool) ruta.Activa }); } // Enlaza los datos con el objeto proveedor RutasCollection lstViewRutas.ItemsSource = _RutasCollection.GetCollection(); Everything is ok but now I would like to check/uncheck all checkboxes in the gridviewcolumn when I press one button or another. How can I do this? Something like this¿? I receive an error that says I can modify itemsource property. private void btnCheckAll_Click(object sender, RoutedEventArgs e) { // Update data object bind to gridview ObservableCollection<RutasData> listas = _RutasCollection.GetCollection(); foreach (var lst in listas) { ((RutasData)lst).Activa = true; } // Update with new values the UI lstViewRutas.ItemsSource = _RutasCollection.GetCollection(); } Thanks!

    Read the article

  • Not able to select a row in my ListView

    - by Krishna Thota
    I'm not able to select a row in my list Item Here is my code <Grid DockPanel.Dock="Left" MinWidth="250"> <ListView x:Name="ListVendors" ItemsSource="{Binding SourceCollection}"> <ListView.View> <GridView> <GridView.ColumnHeaderContainerStyle> <Style><Setter Property="FrameworkElement.Visibility" Value="Collapsed"/></Style> </GridView.ColumnHeaderContainerStyle> <GridViewColumn> <GridViewColumn.CellTemplate> <DataTemplate> <Grid> <Grid.RowDefinitions> <RowDefinition /> <RowDefinition /> <RowDefinition /> </Grid.RowDefinitions> <TextBlock Grid.Row="0" Text="{Binding Name}" FontSize="20"/> <TextBlock Grid.Row="1" Text="{Binding Code}" Foreground="Gray" /> <TextBlock Grid.Row="2" Text="{Binding ContactNo}" Foreground="Gray" /> </Grid> </DataTemplate> </GridViewColumn.CellTemplate> </GridViewColumn> <GridViewColumn> <GridViewColumn.CellTemplate> <DataTemplate> <Grid> <Grid.RowDefinitions> <RowDefinition /> </Grid.RowDefinitions> <TextBlock Grid.Row="0" Text="{Binding Path=Address, Converter={StaticResource addNewLineConv}}" Grid.RowSpan="3" /> </Grid> </DataTemplate> </GridViewColumn.CellTemplate> </GridViewColumn> <GridViewColumn> <GridViewColumn.CellTemplate> <DataTemplate> <Grid> <Grid.RowDefinitions> <RowDefinition /> </Grid.RowDefinitions> <TextBlock Grid.Row="2" Text="{Binding Email}"/> </Grid> </DataTemplate> </GridViewColumn.CellTemplate> </GridViewColumn> <GridViewColumn DisplayMemberBinding="{Binding Email}" Header="Email"/> </GridView> </ListView.View> </ListView> How can I select a row in this ListView?

    Read the article

  • Resize listview in WPF

    - by sDev
    Hi, How to resize listview when main window is resized? Sorry for editing. Want to set the minwidth for gridviewcolumn. So the listview column is set to the min width when page is resized. Is it possible? Thanks SD </GridViewColumn> <GridViewColumn Header="Item"> </GridViewColumn> <GridViewColumn Header="Price"> </GridViewColumn> <GridViewColumn Header="Total Price1"> </GridViewColumn> </GridView> </ListView.View> </ListView> </Grid>

    Read the article

  • Populating a Combobox inside a Gridview

    - by Nawait
    i'm having a few problems working with a gridview and a combobox inside of it. Here is the code for my ListView control: <ListView Height="139" HorizontalAlignment="Left" Margin="10,158,0,0" Name="lvAppointment" VerticalAlignment="Top" Width="250" MinWidth="350"> <ListView.View> <GridView> <GridViewColumn Header="Appointment" Width="120"> <GridViewColumn.CellTemplate> <DataTemplate> <DatePicker SelectedDate="{Binding Path=Appointment}"/> </DataTemplate> </GridViewColumn.CellTemplate> </GridViewColumn> <GridViewColumn Header="Type" Width="170"> <GridViewColumn.CellTemplate> <DataTemplate> <ComboBox ???/> </DataTemplate> </GridViewColumn.CellTemplate> </GridViewColumn> <GridViewColumn Header="Done" Width="50"> <GridViewColumn.CellTemplate> <DataTemplate> <CheckBox IsChecked="{Binding Path=Done}" IsThreeState="False"/> </DataTemplate> </GridViewColumn.CellTemplate> </GridViewColumn> </GridView> </ListView.View> I'm popluating the list from a sql ce database via c# with the following code using (SqlCeCommand sqlCeAppointment = new SqlCeCommand("SELECT appid,appointment,done,apptype.type FROM appointment INNER JOIN apptype ON appointment.refatid = apptype.atid WHERE refeventid = @eventid;", sqlCeConn)) { sqlCeAppointment.Parameters.AddWithValue("@eventid", ((cListEventItem)lvEvent.SelectedItems[0]).id); using (SqlCeDataReader sqlCeAppointmentReader = sqlCeAppointment.ExecuteReader()) { lvAppointment.Items.Clear(); while (sqlCeAppointmentReader.Read()) { lvAppointment.Items.Add(new cListAppointmentItem { id = sqlCeAppointmentReader.GetGuid(sqlCeTerminReader.GetOrdinal("appid")), Appointment = sqlCeAppointmentReader.GetDateTime(sqlCeTerminReader.GetOrdinal("appointment")), Type = sqlCeAppointmentReader.GetString(sqlCeTerminReader.GetOrdinal("type")), Done = sqlCeAppointmentReader.GetByte(sqlCeTerminReader.GetOrdinal("done")) }); } } } I can popluate the list just fine. But i want "Type" to be a combobox so the user can select the apropriate type of the appointment (its a list of appointments connected to an event). This combobox should be filled with data thats inside a table of the sql ce database (apptype). This table is not static, the users can add and delete items from this list. I have tried a few ways i found via google, but failed. I guess i'm having problems understanding how this works/should work. I hope someone can help me :( Thanks in advance

    Read the article

  • How to Set a gridview column width when binding to a datatable

    - by Bob Avallone
    I am binding a table to a gridview in asp.net as such grdIssues.DataSource = mdtIssues; grdIssues.DataBind(); The problem is I cannot then control the column width, asp.net seems to decided on it's own what width each column should be. Methods such as grdIssues.Columns[0].ItemStyle.Width = 100; grdIssues.Columns[1].ItemStyle.Width = 100; don't work because the columns are created dynamically. I cannot believe there isn't a way to do this short of manually creating each column and filling each row. Regards, Bob Avallone

    Read the article

  • ListView + MultipleSelect + MVVM = ?

    - by Dave
    If I were to say "the heck with it!", I could just give my ListView with SelectionMode="Multiple" a name, and be able to get all of the selected items very easily. But I'm trying to stick to MVVM as much as possible, and I want to somehow databind to an ObservableCollection that holds the value from the Name column for each selected item. How in the world do you do this? Single selection is simple, but the multi selection solution is not obvious to me with my current WPF / MVVM knowledge. I read this question on SO, and while it does give me some good insight, I don't know how to add the necessary binding to a row, because I am using a ListView with a GridView as its View, not a ListBox. Here's what my XAML basically looks like: <ListView DockPanel.Dock="Top" ItemsSource="{Binding ClientPreview}" SelectionMode="Multiple"> <ListView.View> <GridView AllowsColumnReorder="False"> <GridViewColumn Header="Name"> <GridViewColumn.CellTemplate> <DataTemplate> <TextBlock Text="{Binding Path=Name}" /> </DataTemplate> </GridViewColumn.CellTemplate> </GridViewColumn> <GridViewColumn Header="Address"> <GridViewColumn.CellTemplate> <DataTemplate> <TextBlock Text="{Binding Path=Address}" /> </DataTemplate> </GridViewColumn.CellTemplate> </GridViewColumn> </GridView> </ListView.View> </ListView> It sounds like the right thing to do is to databind each row's IsSelected property to each object stored in the ObservableCollection I'm databinding to. I just haven't figured out how to do this.

    Read the article

  • Datatemplate binding

    - by Lasse O
    How can i achieve something like this: <ListView Name="OverviewTitlesListView" ItemsSource="{Binding OverviewTitlesCollection}"> <ListView.View> <GridView> <GridViewColumn Header="Index" Width="60" DisplayMemberBinding="{Binding TitleIndex}"/> <GridViewColumn Header="Start Time" Width="100" DisplayMemberBinding="{Binding StartTime}"/> <GridViewColumn Header="End Time" Width="100" DisplayMemberBinding="{Binding EndTime}"/> <GridViewColumn Header="Title Text" Width="550" DisplayMemberBinding="{Binding Text}"/> <GridViewColumn Header="Approved" Width="80"> <GridViewColumn.CellTemplate> <DataTemplate> <TextBlock Name="Test"/> <DataTemplate.Triggers> <Trigger Property="{Binding IsApproved}" Value="true"> <Setter TargetName="Test" Property="Text" Value="Approved"/> </Trigger> <Trigger Property="{Binding IsApproved}" Value="false"> <Setter TargetName="Test" Property="Text" Value="Not Approved"/> </Trigger> </DataTemplate.Triggers> </DataTemplate> </GridViewColumn.CellTemplate> </GridViewColumn> </GridView> </ListView.View> </ListView> When IsApproved property changes on my object in OverviewTitlesCollection i want to control the text of the TextBlock. How can i control this by triggers in my datatemplate?

    Read the article

  • WPF: How to set column width with auto fill in ListView with custom user control.

    - by powerk
    A ListView with Datatemplate in GridViewColumn: <ListView Name ="LogDataList" IsSynchronizedWithCurrentItem="True" ItemsSource="{Binding LogDataCollection}" Background="Cyan"> <ListView.View> <GridView AllowsColumnReorder="true" ColumnHeaderToolTip="Event Log Information"> <GridViewColumn Header="Event Log Name" Width="100"> <GridViewColumn.CellTemplate> <DataTemplate> <l:MyTextBlock Height="25" DataContext="{Binding LogName, Converter={StaticResource DataFieldConverter}}" HighlightMatchCase="{Binding Element}" Loaded="EditBox_Loaded"/> </DataTemplate> </GridViewColumn.CellTemplate> </GridViewColumn> ... </GridView> </ListView.View> </ListView> I have no idea about how to make column width autofill although I have tried a lot of way to walk up. The general idea for demo is : <ListView Name ="LogDataList" IsSynchronizedWithCurrentItem="True" ItemsSource="{Binding LogDataCollection}" Background="Cyan"> <ListView.Resources> <Style x:Key="ColumnWidthStyle" TargetType="{x:Null GridViewColumn}"> <Style.Setters> <Setter Property="HorizontalContentAlignment" Value="Stretch" > </Setter> </Style.Setters> </Style> </ListView.Resources> <ListView.View> <GridView AllowsColumnReorder="true" ColumnHeaderToolTip="Event Log Information"> <GridViewColumn Header="Event Log Name" DisplayMemberBinding="{Binding Path=LogName}" HeaderContainerStyle="{StaticResource ColumnWidthStyle}"> It works, but not accord with my demand. I need to customize datatemplate with my custom user control(MyTextBlock) since the enhancement(HighlighMatchCase property) and binding datacontext. How can I set up ColumnWidthMode with Fill in the word? On-line'in. I really appreciate your help.

    Read the article

  • WPF ListView SelectedItem is null

    - by ozczecho
    Hi All I have a Listview that has a checkbox as one of the columns. If I click anywhere but the actual checkbox the SelectedItem of the ListView is set to the current selected row, as expected. If, on the other hand I click onto the checkbox (without clicking on the row first) then the SelectedItem is null or the previously clicked row. Can anyone help me out.... Cheers <ListView Width="auto" SelectionMode="Single" x:Name="listBox" ItemsSource="{Binding MyData}" SelectedItem="{Binding Path=SelectedMyData}"> <ListView.View> <GridView> <GridViewColumn Header="Date" Width="120"> <GridViewColumn.CellTemplate> <DataTemplate> <ContentPresenter Style="{StaticResource DateTimeContent}" Content="{Binding MyDate}"/> </DataTemplate> </GridViewColumn.CellTemplate> </GridViewColumn> <GridViewColumn.CellTemplate> <DataTemplate> <CheckBox IsThreeState="False" Checked="OnChkChecked" Unchecked="OnChkChecked" IsChecked="{Binding IsCorrect}"></CheckBox> </DataTemplate> </GridViewColumn.CellTemplate> </GridViewColumn> </GridView> </ListView.View> </ListView>

    Read the article

  • WPF ListView's GridView item expansion

    - by NT_
    Is it possible for a WPF ListView that uses a GridView view (ListView.View property) to have one of its items 'expanded' i.e. create some control underneath the item. I cannot simply add another item as it will assume the GridView item template, i.e. appear with columns rather than being a single usable area. This is how my list view currently looks like, it just has two columns: <ListView x:Name="SomeName" Style="{DynamicResource NormalListView}" > <ListView.View> <GridView ColumnHeaderContainerStyle="{DynamicResource NormalListViewHeader}"> <GridViewColumn Width="140" x:Name="Gvc_Name"> <GridViewColumn.CellTemplate> <DataTemplate> <Border Style="{DynamicResource ListViewCellSeparatorBorder}" > <StackPanel Orientation="Vertical" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"> <TextBlock Text="{Binding Path=Name}" FontWeight="Bold" HorizontalAlignment="Left" /> <TextBlock Text="{Binding Path=Type}" HorizontalAlignment="Left" /> </StackPanel> </Border> </DataTemplate> </GridViewColumn.CellTemplate> <Border Style="{DynamicResource ListViewHeaderBorderContainer}"> <TextBlock Style="{DynamicResource ListViewHeaderText}" Text="Name"/> </Border> </GridViewColumn> <GridViewColumn Width="120" x:Name="Gvc_Timestamp"> <GridViewColumn.CellTemplate> <DataTemplate> <Border Style="{DynamicResource ListViewCellSeparatorBorder}"> <StackPanel Orientation="Vertical" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"> <TextBlock Text="{Binding Path=TimestampDate}" HorizontalAlignment="Center" /> <TextBlock Text="{Binding Path=TimestampTime}" FontWeight="Bold" HorizontalAlignment="Center" /> </StackPanel> </Border> </DataTemplate> </GridViewColumn.CellTemplate> <Border Style="{DynamicResource ListViewHeaderBorderContainer}"> <TextBlock Style="{DynamicResource ListViewHeaderText}" Text="Processed"/> </Border> </GridViewColumn> </GridView> </ListView.View> </ListView> Many thanks!

    Read the article

  • How to set property only on second column of a ListView?

    - by Lernkurve
    Introduction I have a ListView and want to format only the second column. The following XAML code does that: <ListView x:Name="listview"> <ListView.View> <GridView> <GridViewColumn Header="Property" DisplayMemberBinding="{Binding Path=Key}" Width="100"/> <!-- <GridViewColumn Header="Value" DisplayMemberBinding="{Binding Path=Value}" Width="250">--> <GridViewColumn Header="Value" Width="250"> <GridViewColumn.CellTemplate> <DataTemplate> <TextBlock Text="{Binding Path=Value}" Foreground="CornflowerBlue" AutomationProperties.Name={Binding Path="Key"}/> </DataTemplate> </GridViewColumn.CellTemplate> </GridViewColumn> </GridView> </ListView.View> </ListView> The one problem I have is that the AutomationProperties.Name property is not being set. I was checking it with the Coded UI Test Builder and the property is empty. The Text and the Foreground property are being set correctly. Question Does anyone know why AutomationProperties.Name is not being set? Additional information Strangly enough, the following XAML code does set the AutomationProperties.Name <ListView x:Name="listview"> <ListView.Resources> <Style TargetType="TextBlock"> <Setter Property="AutomationProperties.Name" Value="{Binding Key}"/> </Style> </ListView.Resources> <ListView.View> <GridView> <GridViewColumn Header="Property" DisplayMemberBinding="{Binding Path=Key}" Width="100"/> <GridViewColumn Header="Value" DisplayMemberBinding="{Binding Path=Value}" Width="250"/> </GridView> </ListView.View> </ListView> The problem here though is that AutomationProperties.Name is being set on all the columns. But I only want it on the second one because otherwise my Coded UI Test code returns the wrong value (that of the first column, instead of that of the second column which I want).

    Read the article

  • How to refactor models without breaking WPF views?

    - by Tim Murphy
    I've just started learning WPF and like the power of databinding it presents; that is ignoring the complexity and confusion for a noob. My concern is how do you safely refactor your models/viewmodels without breaking the views that use them? Take the following snippet of a view for example: <Grid> <ListView ItemsSource="{Binding Contacts}"> <ListView.View> <GridView> <GridViewColumn Header="First Name" DisplayMemberBinding="{Binding Path=FirstName}"/> <GridViewColumn Header="Last Name" DisplayMemberBinding="{Binding Path=FirstName}"/> <GridViewColumn Header="DOB" DisplayMemberBinding="{Binding Path=DateOfBirth}"/> <GridViewColumn Header="# Pets" DisplayMemberBinding="{Binding Path=NumberOfPets}"/> <GridViewColumn Header="Male" DisplayMemberBinding="{Binding Path=IsMale}"/> </GridView> </ListView.View> </ListView> </Grid> The list is bound to the Contacts property, IList(Of Contact), of the windows DataSource and each of the properties for a Contact is bound to a GridViewColumn. Now if I change the name of the NumberOfPets property in the Contact model to PetCount the view will break. How do I prevent the view breaking?

    Read the article

  • How to define 'Attached property' as 'SelectedValuePath' in ComboBox?

    - by SpudCZ
    Hi, I have a problem with binding in ComboBox. I'd like to bind ComboBox items to ListView columns and as a selected value return value of attached property defined on the selected column. In example bellow you can see working sample that displays width of selected column. If you try to change SelectedValuePath in ComboBox into (loc:SampleBehavior.SampleValue) you get binding error: BindingExpression path error: '(u:SearchableListView.SearchMemberPath)' property not found on 'object' ''GridViewColumn' <Window x:Class="Problem_Sample1.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:loc="clr-namespace:Problem_Sample1" WindowStartupLocation="CenterScreen" Title="Window1" Height="300" Width="300"> <DockPanel> <ComboBox DockPanel.Dock="Top" x:Name="combobox" ItemsSource="{Binding Path=View.Columns, ElementName=listview}" DisplayMemberPath="Header" SelectedValuePath="Width"> </ComboBox> <StatusBar DockPanel.Dock="Bottom"> <TextBlock> <TextBlock Text="Selected column (value): " /> <TextBlock Text="{Binding Path=SelectedValue, ElementName=combobox}" /> </TextBlock> </StatusBar> <ListView x:Name="listview"> <ListView.View> <GridView> <GridViewColumn Header="Name" Width="101" loc:SampleBehavior.SampleValue="201" /> <GridViewColumn Header="Surname" Width="102" loc:SampleBehavior.SampleValue="202" /> </GridView> </ListView.View> </ListView> </DockPanel> </Window>   SampleBehavior.cs using System.Windows; using System.Windows.Controls; namespace Problem_Sample1 { public static class SampleBehavior { public static readonly DependencyProperty SampleValueProperty = DependencyProperty.RegisterAttached( "SampleValue", typeof (int), typeof (SampleBehavior)); [AttachedPropertyBrowsableForType(typeof(GridViewColumn))] public static int GetSampleValue(GridViewColumn column) { return (int)column.GetValue(SampleValueProperty); } [AttachedPropertyBrowsableForType(typeof(GridViewColumn))] public static void SetSampleValue(GridViewColumn column, int value) { column.SetValue(SampleValueProperty, value); } } }   Thanks for any help or suggestion.

    Read the article

1 2 3  | Next Page >