Class ObservableBase
Minimal base class for observable objects using pure .NET INotifyPropertyChanged. This class provides framework-agnostic property change notification without external dependencies like CommunityToolkit.Mvvm.
public abstract class ObservableBase : INotifyPropertyChanged
- Inheritance
-
ObservableBase
- Implements
- Derived
- Inherited Members
Methods
OnPropertyChanged(string?)
Raises the PropertyChanged event.
protected virtual void OnPropertyChanged(string? propertyName = null)
Parameters
propertyNamestringThe name of the property that changed.
SetField<T>(ref T, T, Action, string?)
Sets a property value, raises PropertyChanged, and invokes a callback if the value changed.
protected bool SetField<T>(ref T field, T value, Action onChanged, string? propertyName = null)
Parameters
fieldTReference to the backing field.
valueTThe new value.
onChangedActionCallback to invoke after the property changes.
propertyNamestringThe property name (auto-populated by compiler).
Returns
- bool
True if the value changed; otherwise false.
Type Parameters
TThe type of the property.
SetField<T>(ref T, T, Action<T, T>, string?)
Sets a property value, raises PropertyChanged, and invokes a callback with old/new values if the value changed.
protected bool SetField<T>(ref T field, T value, Action<T, T> onChanged, string? propertyName = null)
Parameters
fieldTReference to the backing field.
valueTThe new value.
onChangedAction<T, T>Callback to invoke with old and new values after the property changes.
propertyNamestringThe property name (auto-populated by compiler).
Returns
- bool
True if the value changed; otherwise false.
Type Parameters
TThe type of the property.
SetField<T>(ref T, T, string?)
Sets a property value and raises PropertyChanged if the value changed.
protected bool SetField<T>(ref T field, T value, string? propertyName = null)
Parameters
fieldTReference to the backing field.
valueTThe new value.
propertyNamestringThe property name (auto-populated by compiler).
Returns
- bool
True if the value changed; otherwise false.
Type Parameters
TThe type of the property.
Events
PropertyChanged
Occurs when a property value changes.
public event PropertyChangedEventHandler? PropertyChanged