I have implemented a User Control in which I have bound the DataContext to itself like this...
this.DataContext = this;
There is a Combo box on top of the User Control. On it's selection change event. I am updating a property of the UserControl which should cause the entire View to be regenerated including some tabs in a TabControl and the TextBoxes.
On the selection change event I am updating the property like this...
this.CurrentViewModel = viewModel;
Here is some of the sample xaml from the view.
and inside the TabControl...
UPDATE 1: Here is the CurrentViewModel property
private PageSetupEditorViewModel _currentViewModel;
public PageSetupEditorViewModel CurrentViewModel
{
get { return _currentViewModel; }
set
{
_currentViewModel = value;
OnPropertyChanged(nameof(CurrentViewModel));
}
}
public event PropertyChangedEventHandler PropertyChanged;
public void OnPropertyChanged(string propertyName)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
Can anybody tell me what I am missing here...
UPDATE 2: Sharing the combo selection change event:
private void cmbPageSetupTemplate_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
_errors = 0;
var validPageSetup = cmbPageSetupTemplate.SelectedItem as PageSetupEditorViewModel;
CurrentViewModel = viewModel;
this.DataContext = this;
}
JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)