Skip to content

Instantly share code, notes, and snippets.

@SimonCropp
Created May 31, 2012 11:33
Show Gist options
  • Select an option

  • Save SimonCropp/2842803 to your computer and use it in GitHub Desktop.

Select an option

Save SimonCropp/2842803 to your computer and use it in GitHub Desktop.
public class Person : MyBaseClass
{
public string Name { get; set; }
}
public class MyBaseClass : GalaSoft.MvvmLight.ViewModelBase
{
protected virtual void Broadcast(object oldValue, object newValue, string propertyName)
{
var message = new PropertyChangedMessage(this, this, oldValue, newValue, propertyName);
if (MessengerInstance != null)
{
MessengerInstance.Send(message);
}
else
{
GalaSoft.MvvmLight.Messaging.Messenger.Default.Send(message);
}
}
protected virtual void RaisePropertyChanged(string propertyName, object oldValue, object newValue)
{
RaisePropertyChanged(propertyName);
Broadcast(oldValue, newValue, propertyName);
}
}
public class PropertyChangedMessage : GalaSoft.MvvmLight.Messaging.PropertyChangedMessageBase
{
public PropertyChangedMessage(object sender, object target, object oldValue, object newValue, string propertyName)
: base(sender, target, propertyName)
{
OldValue = oldValue;
NewValue = newValue;
}
public object NewValue { get; set; }
public object OldValue { get; set; }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment