Table of Contents

Class ObservableObjectAttribute

Namespace
CommunityToolkit.Mvvm.ComponentModel
Assembly
CommunityToolkit.Mvvm.dll

An attribute that indicates that a given type should have all the members from ObservableObject generated into it, as well as the INotifyPropertyChanged and INotifyPropertyChanging interfaces. This can be useful when you want the same functionality from ObservableObject into a class that already inherits from another one (since C# doesn't support multiple inheritance). This attribute will trigger the source generator to just create the same APIs directly into the decorated class.

This attribute can be used as follows:

[ObservableObject]
partial class MyViewModel : SomeOtherClass
{
    // Other members here...
}
And with this, the same APIs from ObservableObject will be available on this type as well.
[AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = false)]
public sealed class ObservableObjectAttribute : Attribute
Inheritance
ObservableObjectAttribute
Inherited Members

Constructors

ObservableObjectAttribute()

public ObservableObjectAttribute()