Hi, Create property of type
MainWindowViewModel, and implement
INotifyPropertyChanged interface like this,
private MainWindowViewModel _CurrentViewModel;
public MainWindowViewModel CurrentViewModel
{
get { return _CurrentViewModel; }
set
{
_CurrentViewModel = value;
OnPropertyChanged(new PropertyChangedEventArgs("CurrentViewModel"));
}
}
Refer this CP article for
INotifyPropertyChanged implementation,
Implementing INotifyPropertyChanged[
^]
Now assign
DataContext for
MainWindowViewModel in Window Loaded Event, like,
mn.DataContext = CurrentViewModel;
and to change your viewmodel in button2_Click and button3_Click, just replace following line,
mn.DataContext = new MainWindowViewModel(lstVar, mnoList);
with this line,
CurrentViewModel = new MainWindowViewModel(lstVar, mnoList);