0

I am trying to build an application that contains several user controls. In one, I have a treeview that has been bound to a parent list and in another, I have a datagrid that is supposed to be bound to a child list, only after clicking on a parent item in the treeview.

My question is how to update the datacontext of the datagrid (that is in one usercontrol) by clicking on an item in the treeview (in another usercontrol)

Thanks

4

1 回答 1

0

Here are 2 good options, i'd prefer the first if possible

  • Bind to the same object you need to share.
  • Implement an event aggregator. This is a messaging system in your application. Many documentation can be found on google :)

In this case i believe you can implement the parent's viewmodel to contain a list or ObservableCollection of ViewModels containing the children. This provides the flexibility you require.
Correct me if i'm wrong ;)

于 2013-04-03T11:16:34.240 回答