In my WPF application I have a CheckBox
whose IsChecked
value is bound to a property in my viewmodel. Notice that I have commented out the actual line which sets the value in my viewmodel. It's the standard pattern:
View.xaml
<CheckBox IsChecked="{Binding Path=SomeProperty}" />
ViewModel.cs
public bool SomeProperty
{
get { return this.mSomeProperty; }
set
{
if (value != this.mSomeProperty)
{
//this.mSomeProperty = value;
NotifyPropertyChanged(new PropertyChangedEventArgs("SomeProperty"));
}
}
}
When I click the CheckBox
I expect nothing to happen, since the value of this.mSomeProperty
does not get set. However the observed behavior is that the CheckBox
is being checked and unchecked regardless of the value of this.mSomeProperty
.
What is going on? Why isn't my binding forcing the CheckBox
to show what the underlying data model is set to?