I have been going around with this for a few days, and I hope the WPF guru can see where I am going wrong.
I install CurrentViewModel in code. The selected ListBox and Content list item of my ContentControl will correctly contact. But when you change the selected item in the Listbox through the user interface, CurrentViewModel is installed, but Content Control is not updated.
I use a data template to map my view and view models.
<DataTemplate DataType="{x:Type ViewModel:MyViewModel}">
<View:MyView />
</DataTemplate>
I have a ListBox that is bound to a ViewModels observable collection. The selected item is tied to the current view model.
<ListBox ItemsSource="{Binding MyViewModelCollection}" DisplayMemberPath="DisplayName" SelectedItem="{Binding CurrentViewModel, Mode=TwoWay}"/>
I also have a content control that is also linked to the CurrentView model
<ContentControl Content="{Binding CurrentViewModel, Mode=TwoWay}"/>
This is a property that they are both associated with.
public MyViewModel CurrentViewModel
{
get
{
return _currentViewModel;
}
set
{
if (_currentViewModel== value) return;
_currentViewModel= value;
OnPropertyChanged("CurrentViewModel");
}
}
.
.
,
EDIT: WPF?. Content, , .