This project has moved and is read-only. For the latest updates, please go here.

RaisePropertyChanged(null) not supported.

May 11, 2010 at 6:26 PM
Edited May 11, 2010 at 6:27 PM

Hello everyone,

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 PropertyChangedEventArgs."

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)

            if (!String.IsNullOrEmpty(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.





May 21, 2010 at 10:19 AM


Sorry for the delay.

This does sound like a bug indeed. I logged a bug in my backlog and will get to it in the next version.

In the mean time, I would recommend taking the source file (see the Source Code tab on top of this page) and modifying it yourself. Feel free to include the code in your own project and modify it at will.



Sep 6, 2011 at 11:08 AM

Hi Laurent,

Any update on that point ?

In the meantime, it's possible to have the same behavior as RaisePropertyChanged(string.Empty) by resetting the data context of a view, i.e.:

object currentContext = this.DataContext;
this.DataContext = null;
this.DataContext = currentContext;

But as it must be executed by the view, it requires the view model to raise an event.


Sep 6, 2011 at 11:44 AM
The issue is fixed in V4 beta 1. I am currently in the process of writing the release notes and will publish very soon. In the meantime, I pushed the installer to Skydrive:!845

The MSI will stay available there until I push it to Codeplex. This will be the same file, so feel free to use it already. Let me know if you find issues.