I created a check box and a combo box in a ProWindow. In the xaml file, this is defined as follows:
<CheckBox x:Name="checkBoxSchool" IsChecked="{Binding SchoolChecked}" Content="School"/>
<ComboBox x:Name="comboBoxSchool" ItemsSource="{Binding SchoolItems}" SelectedItem="{Binding SelectedSchoolItem}" IsEnabled="{Binding SchoolComboEnabled}"/>
When the ProWindow is opened, the check box should be disabled. The code in the view model is:
private void InitViewModel()
{
SchoolComboEnabled = false;
}
public bool SchoolComboEnabled
{
get { return _schoolComboEnabled; }
set
{
_schoolComboEnabled = value;
OnPropertyChanged();
}
}
protected void OnPropertyChanged([CallerMemberName] string name = null)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
}
This works.
When the user checks the check box, the combo box should become enabled:
public bool SchoolChecked
{
get { return _schoolChecked; }
set
{
_schoolChecked= value;
if (_schoolChecked)
{
SchoolComboEnabled = true;
OnPropertyChanged();
}
}
}
This doesn't work, i.e. the check box doesn't become enabled.
I tried the exact same code in a dock pane, and it worked! The problem is that I need a window and not a dock pane.
I also created a user control that is embedded in a ProWindow (see ReusableUserControl ) but this doesn't work neither.
Any help is appreciated!