We're currently following MVVM, and need to track the current child record of a parent record. The datagrid is bound to a collectionview of parent items.
So:
ParentViewModel
{
CollectionView Parents {get; set;}
}
class Parent
ObservableCollection Children {get; set;}
Now, the datagrid properly displays our parent records, and you can expand to see the children child records. And, the parent collectionview properly allows us to track the current record, to change current record, add, insert, etc etc.
My question is: We need to iterate through the children of a parent in the viewmodel, and have the grid select the current child record we are processing.
I tried changing Children to a CollectionView from an ObservableCollection, without much luck. Another approach would be to have our view (not the viewmodel) respond to events from the ViewModel, so that when the current item is changed (be it a Parent or Child), an event would be raised with parent/child information, indexes, etc and have the view select the appropriate record).
Any suggestions?
Just a quick note on this: I got the datagrid bound to a collectionview of parent items, with a child collectionview of children items.
Changing the Parent collectionview current item properly updated the grid to the current parent record.
Doing the same for the child collectionview (collectionview.MoveCurrentToLast) for example, did not update the data grid automatically.
So, if the datagrid is bound to a collection with child records, and you wish to update the datagrid to show the current child item being processed, how would you go about that?
You could try to add :
DataType="{x:Type CollectionView}"
to the Field definition of the child collection.
Perhaps the grid would deal with the Current property of the CollectionView has it should.
Hello,
I apologize that this post was not answered sooner. We are making the effort to ensure all posts are addressed by an Infragistics expert.
I was wondering if this is still an outstanding issue. If it yes, would you post the XAML or code for how you are assigning the data bindings to the data.
Thank you,