-
-
Notifications
You must be signed in to change notification settings - Fork 230
MVVMLightBroadcast
Simon Cropp edited this page Jul 30, 2012
·
2 revisions
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; }
}