Datagrid
-
Compared to others i am realy confused with this control. I have 2 classes:
public class DataProcessItem : INotifyPropertyChanged, ICloneable, IEditableObject public class DataProcessList : ObservableCollection
DataProcessItem has exposed properties:public String LongFileName public String ShortFileName public String WindowText public uint Handle public Image FileIcon
so how do i bind DataProcessList to Datagrid and populate? This class will not be used with Dataset or binded from database. I will populate with a code. and second question is how do i add columns and items programaticly without editing xaml. Thank you in advance. Also a code here is not full, only a most important pieces Edit: I am using .NET framework 4.0 so i do not need WPF toolkit -
Compared to others i am realy confused with this control. I have 2 classes:
public class DataProcessItem : INotifyPropertyChanged, ICloneable, IEditableObject public class DataProcessList : ObservableCollection
DataProcessItem has exposed properties:public String LongFileName public String ShortFileName public String WindowText public uint Handle public Image FileIcon
so how do i bind DataProcessList to Datagrid and populate? This class will not be used with Dataset or binded from database. I will populate with a code. and second question is how do i add columns and items programaticly without editing xaml. Thank you in advance. Also a code here is not full, only a most important pieces Edit: I am using .NET framework 4.0 so i do not need WPF toolkitSaksida Bojan wrote:
DataProcessList
You need to set the
ItemSource
of the Datagrid to DataProcessList. To add columns programmatically, useDataGrid.Columns.Add(new DataGridTextColumn());
. You can also have a look at this thread.The funniest thing about this particular signature is that by the time you realise it doesn't say anything it's too late to stop reading it. My latest tip/trick Visit the Hindi forum here.
-
Saksida Bojan wrote:
DataProcessList
You need to set the
ItemSource
of the Datagrid to DataProcessList. To add columns programmatically, useDataGrid.Columns.Add(new DataGridTextColumn());
. You can also have a look at this thread.The funniest thing about this particular signature is that by the time you realise it doesn't say anything it's too late to stop reading it. My latest tip/trick Visit the Hindi forum here.
Does not help me
<DataGrid x:Name="gridSelectProcess" Grid.Row="1" ItemsSource="{Binding Source=local:DataProcessList}" AutoGenerateColumns="True">
</DataGrid>Only thing is that it shows are black empty lines
-
Compared to others i am realy confused with this control. I have 2 classes:
public class DataProcessItem : INotifyPropertyChanged, ICloneable, IEditableObject public class DataProcessList : ObservableCollection
DataProcessItem has exposed properties:public String LongFileName public String ShortFileName public String WindowText public uint Handle public Image FileIcon
so how do i bind DataProcessList to Datagrid and populate? This class will not be used with Dataset or binded from database. I will populate with a code. and second question is how do i add columns and items programaticly without editing xaml. Thank you in advance. Also a code here is not full, only a most important pieces Edit: I am using .NET framework 4.0 so i do not need WPF toolkitFor datagrid you can try WPF DataGrid Practical Examples[^] Well, the example is using toolkit, but you can easily adjust the code to use your own DataGrid, as the process remains same. You can also use Grid using ListView[^] to create grid using Listview in WPF if you wish.
Abhishek Sur **Don't forget to click "Good Answer" if you like this Solution.
Visit My Website-->**
-
For datagrid you can try WPF DataGrid Practical Examples[^] Well, the example is using toolkit, but you can easily adjust the code to use your own DataGrid, as the process remains same. You can also use Grid using ListView[^] to create grid using Listview in WPF if you wish.
Abhishek Sur **Don't forget to click "Good Answer" if you like this Solution.
Visit My Website-->**
I did attempt to read that article. For me it confusing, because it uses DataSet and it is binded to northwind databas, while i wan't to use a custom class in non database driven source. (Such as .Accsess, MySQL or MSSQL). Gonna save in xml with a specific format. This format would be a collection of sevral diffrent types of items. also Grid using ListView seems promesing gonna check it out. Edit: Got it working, however i needed to put ItemSource in code behind, not in xaml. Final question about datagrid. How do i make DataGrid to show images? thank you for your time
modified on Wednesday, September 22, 2010 4:28 PM