dotnet icon indicating copy to clipboard operation
dotnet copied to clipboard

Visual Studio Designer report "invalid markup" when View-Model class derived from ObservableObject

Open zvilius opened this issue 2 years ago • 0 comments

Describe the bug

Developing a WPF desktop app for .NET Framework 4.8, I find that when I derive my View-Model class from ObservableObject, the Visual Studio 2022 Designer says "invalid markup".

The reported error is: Error XDG0047 The specified value cannot be assigned. The following type was expected: "Object". foo C:\XXX\foo\MainWindow.xaml 11

Line 11 in MainWindow.xaml is: <c:ViewModel x:Key="vm" />

The ViewModel class is declared as:

    internal class ViewModel : ObservableObject
    {
        public SomeStruct SomeProperty {
            get => this.some_property;
            private set => SetProperty(ref this.some_property, value);
        }
    .. etc ..

Regression

No response

Steps to reproduce

.NET Framework 4.8
Visual Studio 2022
WPF App for .NET Framework

See other details above.

Expected behavior

Visual Studio Designer should be able to preview my UI.

Screenshots

No response

IDE and version

VS 2022

IDE version

Microsoft Visual Studio Professional 2022 (64-bit) - Current Version 17.1.4

Nuget packages

  • [ ] CommunityToolkit.Common
  • [ ] CommunityToolkit.Diagnostics
  • [ ] CommunityToolkit.HighPerformance
  • [X] CommunityToolkit.Mvvm (aka MVVM Toolkit)

Nuget package version(s)

7.1.2

Additional context

No response

Help us help you

No, just wanted to report this

zvilius avatar Apr 18 '22 00:04 zvilius