microsoft-ui-xaml: Adding Resource doesn't work in WinUI 3 for desktop

When adding a xaml resource the project doesn’t compile

<Grid.Resources>
     <local:MyClass x:Key="asdf"/>
</Grid.Resources>

Error WMC0026 Cannot add ‘MyClass’ into the dictionary property ‘Resources’, type must be ‘Object’ C:\Projects\XXXXXX\MainWindow.xaml 48

Additionally the Window object has no Resource property.

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 4
  • Comments: 15 (11 by maintainers)

Most upvoted comments

I don’t think it needs to be DependencyObject in order to be placed in the resource dictionary. If it takes object, that should just work. Perhaps the markup compiler is getting tripped by something. @stevenbrix @alwu-msft any ideas ?