I will first discuss the mere syntactical error that the compiler is complaining about:
You invoke
new PropertyChangedEventArgs(resetButton.IsEnabled = false)
In there, the expression
resetButton.IsEnabled = false
will evaluate to a bool
. Hence, you are passing a bool
to the constructor of PropertyChangedEventArgs
.
However, that constructor expects a string
, namely the name of the changed property.
Now, concerning the intended result:
I am using the following command to update the button on GUI
No, you are not. At least, not directly.
What you can use the call to PropertyChanged
for is to fire any event handlers registered with the PropertyChanged
event, which can then do whatever you want them to do, e.g. update something in the GUI.
Therefore, somewhere else in the code, you have to write something like this:
myObject.PropertyChanged += delegate(object sender, PropertyChangedEventArgs e)
{
resetButton.IsEnabled = false;
}
This creates an anonymous method and registers it as an event handler with your event.
Now, usually, you will also want to check the PropertyName
property on the e
argument to see which property of myObject
has actually been changed.
And here, we get back to your firing of the event: You have to pass in the property name of the changed property upon constructing the PropertyChangedEventArgs
instance.
If your property is of type bool
(or if you have an appropriate value converter to convert whatever type your property is to bool
), you can also directly bind the resetButton.IsEnabled
property in XAML to your property. It will then automatically register a handler with the PropertyChanged
event under the hood in order to update the enabled state of the button when required.