But, in software development there is no silver bullet. So here is a issue I ran across when using the property change message.
Null Reference exception on the receiver.
In my publisher view model I had the following property
public String MyProperty
{
get { return _myProperty; }
set
{
if (value == _myProperty) return;
var oldValue = _myProperty;
_myProperty= value;
RaisePropertyChanged("MyProperty", oldValue, value, true);
}
}
private _myProperty;
In the reciever view Model I Registered and handled the message
Messenger.Default.Register<PropertyChangedMessage<MyObject>>(this,HandlePropertyChanged);
private void HandlePropertyChanged(PropertyChangedMessage<MyObject> propertyChangedMessage)
{
if (propertyChangedMessage.PropertyName != "MyProperty") return;
if( propertyChangedMessage.NewValue != null)
JobNumber = propertyChangedMessage.NewValue;
}
In the app.xaml.cs I added
DispatcherHelper.Initialize();
No more null reference exception.