Reputation: 81
I have a WPF window with a few checkboxes. I want to bind these checkboxes to boolean properties in my object, so changes in data will be reflected in view, and changes in view will be reflected in data. Do I have to derive this object from INotifyPropertyChanged?
Upvotes: 1
Views: 125
Reputation: 13207
As the documentation suggestes, you will have to do so. You must provide properties
and inside those properties
fire the PropertyChangedEvent
.
Here is an example from the documentation:
public string PhoneNumber
{
get
{
return this.phoneNumberValue;
}
set
{
if (value != this.phoneNumberValue)
{
this.phoneNumberValue = value;
NotifyPropertyChanged();
}
}
}
You will need to make this fit to your needs, though. Please have a look at MSDN on how to implement the interface properly.
Upvotes: 3
Reputation: 31192
Yes, otherwise when you change values in your object, the checkboxes' bindings won't update properly.
Upvotes: 1