/// <summary> /// Raises the PropertyChanged event if needed, and broadcasts a /// PropertyChangedMessage using the Messenger instance (or the /// static default instance if no Messenger instance is available). /// </summary> /// <typeparam name="T">The type of the property that /// changed.</typeparam> /// <param name="propertyExpression">An expression identifying the property /// that changed.</param> /// <param name="oldValue">The property's value before the change /// occurred.</param> /// <param name="newValue">The property's value after the change /// occurred.</param> /// <param name="broadcast">If true, a PropertyChangedMessage will /// be broadcasted. If false, only the event will be raised.</param> protected virtual void RaisePropertyChanged <T>(Expression <Func <T> > propertyExpression, T oldValue, T newValue, bool broadcast) { PropertyChangedEventHandler propertyChangedHandler = base.PropertyChangedHandler; if ((propertyChangedHandler != null) || broadcast) { string propertyName = BindableObject.GetPropertyName <T>(propertyExpression); if (propertyChangedHandler != null) { propertyChangedHandler(this, new PropertyChangedEventArgs(propertyName)); } if (broadcast) { this.Broadcast <T>(oldValue, newValue, propertyName); } } }