I have the task to write a user control to display some results by using the MVVM patern.
The main application (called ApplicationVM) has two a properties UserControlViewModel and SelectedRecord. The first property contains an instance of the UserControlViewModel. In XAML I use these property to bind the UserControl to the UserControlViewModel. The DependencyProperty PageCount is for simple notifications between a display function in the view and the UserControlViewModel.
<control:UserControl DataContext="{Binding UserControlViewModel}" PageCount="{Binding DocumentPageCount}" />
Here is the implementation of the second property in the ApplicationViewModel.
public Record SelectedRecord
{
get
{
return m_SelectedRecord;
}
set
{
m_SelectedRecord = value;
OnPropertyChanged("SelectedRecord");
}
}
Later, this property will by replaced. But what I should to do is to make a dependency between the property "SelectedRecord" and a "Record" of the "UserControlViewModel" which calls a function to generate the new content (e.g. GenerateContent()). How can I make it possible that a change of the SelectedRecord property updates the Record Property of the UserControlViewModel to genereate the new content? Or can my UserControlViewModel hear the OnPropertyChanged("SelectedRecord") to generate automaticcly new content?