docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class ObservableObject

    A base class for objects of which the properties must be observable.

    Inheritance
    object
    ObservableObject
    Implements
    INotifyPropertyChanged
    INotifyPropertyChanging
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: Unity.AppUI.MVVM
    Assembly: Unity.AppUI.MVVM.dll
    Syntax
    public abstract class ObservableObject : INotifyPropertyChanged, INotifyPropertyChanging

    Methods

    OnPropertyChanged(PropertyChangedEventArgs)

    Raises the PropertyChanged event.

    Declaration
    protected virtual void OnPropertyChanged(PropertyChangedEventArgs e)
    Parameters
    Type Name Description
    PropertyChangedEventArgs e

    The event data.

    Exceptions
    Type Condition
    ArgumentNullException

    e is null.

    OnPropertyChanged(string?)

    Raises the PropertyChanged event.

    Declaration
    protected void OnPropertyChanged(string? propertyName = null)
    Parameters
    Type Name Description
    string propertyName

    The name of the property that has changed.

    OnPropertyChanging(PropertyChangingEventArgs)

    Raises the PropertyChanging event.

    Declaration
    protected virtual void OnPropertyChanging(PropertyChangingEventArgs e)
    Parameters
    Type Name Description
    PropertyChangingEventArgs e

    The event data.

    Exceptions
    Type Condition
    ArgumentNullException

    e is null.

    OnPropertyChanging(string?)

    Raises the PropertyChanging event.

    Declaration
    protected void OnPropertyChanging(string? propertyName = null)
    Parameters
    Type Name Description
    string propertyName

    The name of the property that is changing.

    SetProperty<T>(T, T, Action<T>, string?)

    Sets the property and raises the PropertyChanging and PropertyChanged events.

    Declaration
    protected bool SetProperty<T>(T oldValue, T newValue, Action<T> callback, string? propertyName = null)
    Parameters
    Type Name Description
    T oldValue

    The old value.

    T newValue

    The new value.

    Action<T> callback

    The callback to invoke to set the property.

    string propertyName

    The name of the property that has changed.

    Returns
    Type Description
    bool

    true if the property has changed, false otherwise.

    Type Parameters
    Name Description
    T

    The type of the property.

    Exceptions
    Type Condition
    ArgumentNullException

    callback is null.

    SetProperty<T>(T, T, EqualityComparer<T>, Action<T>, string?)

    Sets the property and raises the PropertyChanging and PropertyChanged events.

    Declaration
    protected bool SetProperty<T>(T oldValue, T newValue, EqualityComparer<T> comparer, Action<T> callback, string? propertyName = null)
    Parameters
    Type Name Description
    T oldValue

    The old value.

    T newValue

    The new value.

    EqualityComparer<T> comparer

    The comparer to use to check if the property has changed.

    Action<T> callback

    The callback to invoke to set the property.

    string propertyName

    The name of the property that has changed.

    Returns
    Type Description
    bool

    true if the property has changed, false otherwise.

    Type Parameters
    Name Description
    T

    The type of the property.

    Exceptions
    Type Condition
    ArgumentNullException

    callback or comparer is null.

    SetProperty<T>(ref T, T, EqualityComparer<T>, string?)

    Sets the property and raises the PropertyChanging and PropertyChanged events.

    Declaration
    protected bool SetProperty<T>(ref T field, T newValue, EqualityComparer<T> comparer, string? propertyName = null)
    Parameters
    Type Name Description
    T field

    The field to set.

    T newValue

    The new value.

    EqualityComparer<T> comparer

    The comparer to use to check if the property has changed.

    string propertyName

    The name of the property that has changed.

    Returns
    Type Description
    bool

    true if the property has changed, false otherwise.

    Type Parameters
    Name Description
    T

    The type of the property.

    Exceptions
    Type Condition
    ArgumentNullException

    comparer is null.

    SetProperty<T>(ref T, T, string?)

    Sets the property and raises the PropertyChanging and PropertyChanged events.

    Declaration
    protected bool SetProperty<T>(ref T field, T newValue, string? propertyName = null)
    Parameters
    Type Name Description
    T field

    The field to set.

    T newValue

    The new value.

    string propertyName

    The name of the property that has changed.

    Returns
    Type Description
    bool

    true if the property has changed, false otherwise.

    Type Parameters
    Name Description
    T

    The type of the property.

    SetProperty<T, TModel>(T, T, TModel, Action<TModel, T>, string?)

    Sets the property and raises the PropertyChanging and PropertyChanged events.

    Declaration
    protected bool SetProperty<T, TModel>(T oldValue, T newValue, TModel model, Action<TModel, T> callback, string? propertyName = null)
    Parameters
    Type Name Description
    T oldValue

    The old value.

    T newValue

    The new value.

    TModel model

    The model to set the property on.

    Action<TModel, T> callback

    The callback to invoke to set the property.

    string propertyName

    The name of the property that has changed.

    Returns
    Type Description
    bool

    true if the property has changed, false otherwise.

    Type Parameters
    Name Description
    T

    The type of the property.

    TModel

    The type of the model.

    Exceptions
    Type Condition
    ArgumentNullException

    callback or model is null.

    Events

    PropertyChanged

    Occurs when a property value has changed.

    Declaration
    public event PropertyChangedEventHandler? PropertyChanged
    Event Type
    Type Description
    PropertyChangedEventHandler

    PropertyChanging

    Occurs when a property value is changing.

    Declaration
    public event PropertyChangingEventHandler? PropertyChanging
    Event Type
    Type Description
    PropertyChangingEventHandler

    Implements

    INotifyPropertyChanged
    INotifyPropertyChanging
    In This Article
    • Methods
      • OnPropertyChanged(PropertyChangedEventArgs)
      • OnPropertyChanged(string?)
      • OnPropertyChanging(PropertyChangingEventArgs)
      • OnPropertyChanging(string?)
      • SetProperty<T>(T, T, Action<T>, string?)
      • SetProperty<T>(T, T, EqualityComparer<T>, Action<T>, string?)
      • SetProperty<T>(ref T, T, EqualityComparer<T>, string?)
      • SetProperty<T>(ref T, T, string?)
      • SetProperty<T, TModel>(T, T, TModel, Action<TModel, T>, string?)
    • Events
      • PropertyChanged
      • PropertyChanging
    • Implements
    Back to top
    Copyright © 2024 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)