Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fail to find resources from within non-primary ResourceDictionary #8832

Open
artkat opened this issue Sep 5, 2023 · 4 comments
Open

Fail to find resources from within non-primary ResourceDictionary #8832

artkat opened this issue Sep 5, 2023 · 4 comments
Labels
area-Resources bug Something isn't working team-Markup Issue for the Markup team

Comments

@artkat
Copy link

artkat commented Sep 5, 2023

Describe the bug

App throws 'XAML parsing failed' 'Cannot find resource with the Name/Key...' when trying to lookup a default value (brush) or custom theme resource value (color or brush) from with a resource dictionary other than app.xaml.

Seems the app is not able to resolve resources referenced in additional (non App.xaml) resource dictionaries. Neither the standard WinUI control styles/resources, nor the theme resources defined in App.xaml can be resolved.

Sample code to demonstrate this issue can be found on GitHub: https://github.com/artkat/WinUIResourcesTest

Steps to reproduce the bug

  1. Download and compile/run sample from https://github.com/artkat/WinUIResourcesTest - it will crash with said exception
  2. First error is in FirstResourceDictionary.xaml - when Microsoft.UI.Xaml.Controls is included (marked-out block), it will not crash on this
  3. Second error is in SecondResourceDictionary - MyBrush, which is defined as an app.xaml theme resource, cannot be found.

Expected behavior

Should run fine and be able to find the resources.

Screenshots

No response

NuGet package version

WinUI 3 - Windows App SDK 1.4.0: 1.4.230822000

Windows version

Windows 11 (22H2): Build 22621

Additional context

No response

@artkat artkat added the bug Something isn't working label Sep 5, 2023
@DarranRowe
Copy link

Just to let you know, as of the time of writing, your linked repo only has a .gitignore file.

@artkat
Copy link
Author

artkat commented Sep 6, 2023

@DarranRowe oops. Thanks. Forgot to push the repo. Should be there now

@bpulliam bpulliam added team-Markup Issue for the Markup team area-Resources labels Sep 7, 2023
@shane-vorwerk
Copy link

I am also running into issues with resources not working as expected. I created a control in code derived from ContentDialog and was not able to apply any styles to it.

@Xo3-ToBapbl
Copy link

Xo3-ToBapbl commented Nov 22, 2023

Please, try to add more than one style to your recourse dictionary. In my case I had the same exception with only ONE style in resource dictionary, but when I added another style, everything worked as expected.

FYI: I've already seen similar issue, and it's a shame that MS can't fix this for years. And as usual, after months, silence is the answer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-Resources bug Something isn't working team-Markup Issue for the Markup team
Projects
None yet
Development

No branches or pull requests

5 participants