Created
May 31, 2012 11:33
-
-
Save SimonCropp/2842803 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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