May 11, 2010 at 6:26 PM
Edited May 11, 2010 at 6:27 PM
First, a huge thank-you to Laurent for not only this toolkit, but all of the tutorials and help you so generously provide to the community!
I've started my first C#/WPF project using the toolkit, and have been creating my ViewModel's from the toolkit's ViewModelBase. Everything has been working wonderfully until I needed to use a particular feature of INotifyPropertyChanged that allows one to
fire a PropertyChanged event for all properties at once.
The MSDN documentation for INotifyPropertyChanged states that "The
PropertyChanged event can indicate all properties on the object have changed by using either
null or String.Empty as the property name in the
When I attempt to do this using the ViewModelBase, it fails with an ArgumentNullException from mscorlib in the case of RaisePropertyChanged(null), and an ArgumentException from GalaSoft.MvvmLight.WPF4.dll in the case of RaisePropertyChanged(String.Empty).
I don't know whether this would be considered a bug in the ViewModelBase, or if this functionality was intentially left out. Either way, I'm guessing my only option is to override the RaisePropertyChanged(string propertyName) method and either fire
the event directly if String.IsNullOrEmpty(propertyName), or pass it along to base.RaisePropertyChange(propertyName) for standard behaviour. However, being as new as I am to C#, I haven't found a way to make this work. Here is the code I tried:
protected override void RaisePropertyChanged(string propertyName)
var handler = base.PropertyChanged;
if (handler != null)
handler(this, new PropertyChangedEventArgs(null));
The issue I'm having is that "base.PropertyChanged" is not valid, and I'm not clear why, or how best to fire the event directly from my derived ViewModel. Any suggestions would be very much appreciated.