I have the following method:
void ViewModelPropertyChanged(object sender, PropertyChangedEventArgs e)
{
switch (e.PropertyName)
{
case "InitializeFailureMessage":
if (Vm.InitializeFailureMessage != null)
ShowInitializeFailure(Vm.InitializeFailureMessage);
break;
}
}
Just now, the method had a bug: the property used to be called InitializeFailureErrorMessage
, and when it was renamed, no one updated the string in this handler.
Is there a better, less error-prone way to subscribe to the PropertyChanged
event? When firing the event we can now use [CallerMemberName]
. Is there a similar trick when implementing the handler?