ObservableObjectBase Class
A simple object that implements the INotifyPropertyChanging and INotifyPropertyChanged interfaces.
public abstract class ObservableObjectBase
- Inheritance:
- object object
- Derived:
- TextDocumentBase BarGalleryItemViewModel<TValue> BarHeadingViewModel BarKeyedObjectViewModelBase BarMainMenuViewModel BarSeparatorViewModel DockableToolBarHostViewModel MiniToolBarViewModel RibbonApplicationButtonViewModel RibbonBackstageHeaderSeparatorViewModel RibbonBackstageViewModel RibbonControlGroupViewModel RibbonFooterInfoBarContentViewModel RibbonFooterSimpleContentViewModel RibbonFooterViewModel RibbonMultiRowControlGroupViewModel RibbonQuickAccessToolBarViewModel RibbonTabRowToolBarViewModel RibbonViewModel StandaloneToolBarViewModel LegendKey DataPointBase DataModelBase CategoryEditor CategoryEditorProperty PropertyEditor MicroDataPointBase NavigationBarOptionsWindowItem RibbonWindowTitleBarViewModel ShellObjectViewModel HighlightingStyle EditorSearchOptions ThemeDefinition
Constructors
ObservableObjectBase()
Initializes an instance of the class.
protected ObservableObjectBase()
Methods
NotifyPropertyChanged(string)
Notifies that a property has changed.
[Browsable(false)]
[Obsolete("Use one of the new SetProperty or OnPropertyChanged methods instead of this deprecated NotifyPropertyChanged method.", false)]
protected void NotifyPropertyChanged(string propertyName)
| Parameter | Type | Description |
|---|---|---|
| propertyName | string | The name of the property that was changed. |
Remarks
This method is deprecated and retained for backward compatibility. It only raises the PropertyChanged event and does not raise the new PropertyChanging event. This method should not be used in new code. Instead, use the SetProperty<T>(ref T, T, string?) method to set property values and raise change notifications. Alternatively, call the OnPropertyChanged(string?) method to just raise the PropertyChanged event.
OnPropertyChanged(PropertyChangedEventArgs)
Raises the PropertyChanged event.
protected virtual void OnPropertyChanged(PropertyChangedEventArgs e)
| Parameter | Type | Description |
|---|---|---|
| e | PropertyChangedEventArgs | The event data. |
OnPropertyChanged(string?)
Raises the PropertyChanged event.
protected void OnPropertyChanged(string? propertyName = null)
| Parameter | Type | Description |
|---|---|---|
| propertyName | string | (Optional) The name of the property that changed. |
OnPropertyChanging(PropertyChangingEventArgs)
Raises the PropertyChanging event.
protected virtual void OnPropertyChanging(PropertyChangingEventArgs e)
| Parameter | Type | Description |
|---|---|---|
| e | PropertyChangingEventArgs | The event data. |
OnPropertyChanging(string?)
Raises the PropertyChanging event.
protected void OnPropertyChanging(string? propertyName = null)
| Parameter | Type | Description |
|---|---|---|
| propertyName | string | (Optional) The name of the property that changed. |
SetProperty<T>(ref T, T, string?)
Called from a property setter to change the backing field's value and raise PropertyChanging and PropertyChanged notification events if the new value is not equal to the current value.
protected bool SetProperty<T>(ref T field, T newValue, string? propertyName = null)
- Type Parameters:
-
T-The type of the property that changed.
| Parameter | Type | Description |
|---|---|---|
| field | T | The backing field that holds the property's value, which may be updated. |
| newValue | T | The new property value. |
| propertyName | string | (Optional) The name of the property that changed. |
Returns
- bool:
trueif the property was changed; otherwise,false.
Events
PropertyChanged
Occurs when a property value changes.
PropertyChanging
Occurs when a property value is changing.
Inherited Members
- object.GetType()
- object.MemberwiseClone()
- object.ToString()
- object.Equals(object)
- object.Equals(object, object)
- object.ReferenceEquals(object, object)
- object.GetHashCode()