in Education by
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)

1 Answer

0 votes
by
So apparently, I had to do two things to make it work. Since I was binding the User Control to itself like this... this.DataContext = this; I had to implement INotifyPropertyChange on the User Control class itself and implement the PropertyChanged call on the CurrentViewModel property, like this: 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)); } But that did not entirely updated the view as I was using a collection to generate tabs in the TabControl. I had to refresh the view for TabComtrol.Items using this on the selection of ComboBox's selection change event, like this: tcOrientation.Items.Refresh(); This solved the problem for me :)

Related questions

0 votes
    I am working on WPF application.I have bound my textblock to my button. I want to set foreground ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 19, 2022 in Education by JackTerrance
0 votes
    I am working on WPF application.I have bound my textblock to my button. I want to set foreground ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 18, 2022 in Education by JackTerrance
0 votes
    This question is specifically related to overriding the equals() method for objects with a large number of ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 17, 2022 in Education by JackTerrance
0 votes
    During inspect and adapt event which is a regular time to reflect, problem-solve, and take on improvement actions needed to...
asked Nov 30, 2020 in Technology by Editorial Staff
0 votes
    What is the Git command to view all the changes since the last commit ? A. git clean B. git status C. git changes D. git commit...
asked Dec 21, 2022 in Technology by JackTerrance
0 votes
    How should organizations view market changes?...
asked Nov 28, 2020 in Technology by JackTerrance
0 votes
    I am using MacOS Monterey 12.3. Once I initialize git for my Python (Python3.9) project, if I ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 7, 2022 in Education by JackTerrance
0 votes
    If birds are moved from 30°C - 10°C, their body temperature (a) changes from 30°C - 10°C (b ... Science,Science proposed by,electromagnetic theory engineering physics,Science nptel...
asked Nov 8, 2021 in Education by JackTerrance
0 votes
    having this code block of an example rails model class: class Block < ActiveRecord::Base has_many :bricks, ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 12, 2022 in Education by JackTerrance
0 votes
    I am trying to understand ViewModel and LiveData. In MainActivity, I am observing LiveData In MyTask, I am ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 14, 2022 in Education by JackTerrance
0 votes
    I am trying to understand ViewModel and LiveData. In MainActivity, I am observing LiveData In MyTask, I am ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 13, 2022 in Education by JackTerrance
0 votes
    I've got the following code in my MainPage.xaml.cs public partial class MainPage : UserControl { private ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jan 16, 2022 in Education by JackTerrance
0 votes
    I am able to create and run a simple GWT application by creating all the files myself. It works ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 20, 2022 in Education by JackTerrance
0 votes
    Below is a crude for-loop to illustrate what I need to do. Basically, if there are any 'Variable' ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 20, 2022 in Education by JackTerrance
0 votes
    Below is a crude for-loop to illustrate what I need to do. Basically, if there are any 'Variable' ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 14, 2022 in Education by JackTerrance
...