Answer the question
In order to leave comments, you need to log in
Who can tell me how to work with CollectionView / CollectionViewSource in WPF?
Faced a problem of work with the data bound to DataGrid. It is necessary to implement automatic updating of source elements, data validation, grouping, filtering. Everything should be generated in code (no writing in XAML). To be honest, I'm just confused - what to use for what: ObservableCollection / CollectionView / CollectionViewSource, what to inherit from, etc. In Google, the information is very scarce. Can someone on skype advise on the implementation?
Answer the question
In order to leave comments, you need to log in
I can google and here. It's not good to leave contacts, so at least hide them in the comments, I'll get in touch.
Ok, in short, there is an ObservableCollection, and when you create a collection, you then equate it to DataGrid.ItemSource:
struct Some {
String a;
int b;
}
/***/
DataGrid dataGrid = /***/;
ObservableCollection<Some> s = new /***/;
s.Add(new Some{a = "A", b = 1});
s.Add(new Some{a = "B", b = 2});
/** forget how to bind struct to data grid, check below**/
dataGrid.ItemSource = s;
/***/
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question