Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
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
- You can find more examples in the unit tests.
MVVM Toolkit