Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
45
Tracking current child record of a bound collectionview
posted

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?

 

 

Parents Reply Children
No Data