Edit

Share via


MVVM Toolkit warning MVVMTK0050

Using the [ObservableObject] attribute on types is not AOT compatible in WinRT scenarios (such as UWP XAML and WinUI 3 apps), and they should derive from ObservableObject instead (as it allows the CsWinRT generators to correctly produce the necessary WinRT marshalling code).

The following sample generates MVVMTK0050:

using CommunityToolkit.Mvvm.ComponentModel;

namespace MyApp;

[ObservableObject]
public partial class SampleViewModel
{    
}

You should instead derive from ObservableObject:

using CommunityToolkit.Mvvm.ComponentModel;

namespace MyApp;

public partial class SampleViewModel : ObservableObject
{    
}

Additional resources