You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The original INotifyPropertyChanged allows a user to pass a PropertyChangedEventArgs of null or String.Empty as a shorthand for updating all registered bindings on the current ViewModel.
After looking over your code I found re-enabling this was VERY simple.
By simply adding "|| String.IsNullOrEmpty(e.PropertyName)" to the if statement the expected behavior can be achieved. Since the PropertyWatcher class is already designed to be limited to the scope of the current view model, no further code is needed.
That's interesting. When do you think this would be useful? I generally try to avoid firing events unless I know they're definitely necessary but I'd consider adding this if there's a good use-case for it.
The most common example is when most of your fields are linked to an object, and that object has changed. Basically, instead of having to maintain a list of things to update you can simply pass null to fire to all registered listeners at the current scope.
This is also the normal behavior for PropertyChanged in WPF and Silverlight.
The original INotifyPropertyChanged allows a user to pass a PropertyChangedEventArgs of null or String.Empty as a shorthand for updating all registered bindings on the current ViewModel.
After looking over your code I found re-enabling this was VERY simple.
Inside PropertyWatcher.cs at the bottom you have:
private void propertyOwner_PropertyChanged(object sender, PropertyChangedEventArgs e) { if (e.PropertyName == propertyName) { action(); } }
By simply adding "|| String.IsNullOrEmpty(e.PropertyName)" to the if statement the expected behavior can be achieved. Since the PropertyWatcher class is already designed to be limited to the scope of the current view model, no further code is needed.
private void propertyOwner_PropertyChanged(object sender, PropertyChangedEventArgs e) { if (e.PropertyName == propertyName || String.IsNullOrEmpty(e.PropertyName)) { action(); } }
The text was updated successfully, but these errors were encountered: