I have two user control. The second one has a datagrid. I want the first user control to be notified when the selected item in the datagrid of the second user control is changed.
Is it possible bind properties of different user controls?
I was thinking about this:
<local:MyFirstUserControl MyPorperty={Binding ElementName MySecondUserControl, path=DataGrid.Selecteditem}/>
<local:MyFirstUserControl Name="MySecondUserControl"/>
Thanks.
You can use a messenger to send messages between view models (e.g DevExpress.Mvvm or MvvmLight)
https://docs.devexpress.com/WPF/17474/mvvm-framework/messenger
You can define and subscribe custom events. In your case, first user control would subscribe to some event (let's say event X) Second user control would publish event X with the corresponding object(selected item in your case). First user control will get notified each time selected item changed, get the data and do the processing.