Skip to content

[Investigation] Are our named Resources Exposed to Applications Properly? #3603

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

Open
michael-hawker opened this issue Dec 4, 2020 · 6 comments
Labels
bug 🐛 An unexpected issue that highlights incorrect behavior build 🔥 good first issue Issues identified as good for first-time contributors help wanted Issues identified as good community contribution opportunities improvements ✨ need more info 📌 open discussion ☎️ question ❔ Issues or PR require more information

Comments

@michael-hawker
Copy link
Member

See start of discussion on this thread here: #3556 (comment)

Describe the bug

When a developer uses the Toolkit they should have access to the style/resources we expose in order to use them as a basis for modifications. On the discussion above, it's unclear if that's happening properly or not...

Steps to Reproduce

Steps to reproduce the behavior:

  1. Start a new project
  2. Include the Controls package
  3. Go to MainPage
  4. Add <Page.Resources> and try and create a new style based on a DefaultTokenizingTextBoxStyle
  5. Try to use a new style on the control
  6. Compile... does this work?

Expected behavior

It should work...

Related to #3602

@michael-hawker michael-hawker added bug 🐛 An unexpected issue that highlights incorrect behavior help wanted Issues identified as good community contribution opportunities question ❔ Issues or PR require more information need more info 📌 open discussion ☎️ improvements ✨ build 🔥 good first issue Issues identified as good for first-time contributors labels Dec 4, 2020
@michael-hawker michael-hawker added this to the 7.0 milestone Dec 4, 2020
@alvinashcraft
Copy link
Contributor

So, when I try this, IntelliSense tells me that the DefaultTokenizingTextBoxStyle is not found. It compiles fine, but I get a Xaml error at runtime during app startup.

@michael-hawker
Copy link
Member Author

Thanks for taking a look @alvinashcraft so seems like we may be missing something to expose these. I wonder if this works differently in UWP and that's why WinUI forces the add to App.xaml?

@ranjeshj do you know who we'd talk to about how this system works and if this is expected or not?

@yoshiask
Copy link
Contributor

yoshiask commented Jan 6, 2021

I wonder if this works differently in UWP and that's why WinUI forces the add to App.xaml?

I'm pretty sure this is correct, I vaguely remember someone from the WinUI team mentioning this limitation. Might have been an early community call or something.

Are there any updates on this investigation? Is the WCT going to do the same as WinUI?

@michael-hawker
Copy link
Member Author

I think this is a platform limitation and related to this issue here maybe? microsoft/microsoft-ui-xaml#3502

@sylveon
Copy link

sylveon commented Jul 4, 2021

Accessing named resources defined in Themes\Generic.xaml doesn't even work from within the same project, so it seems like an intentional design choice that the resources in there aren't added to the application's resources by default.

@marcelwgn
Copy link
Contributor

@sylveon Is 100% correct, this seems to be by design. Styles inside Themes\Generic.xaml files will be used to lookup the default style, however resource wise, you can't access them. Only way to access them is by manually adding them to the resources dictionary (e.g. through merged dictionaries). This is also what WinUI does. Not that manually referencing the resources will also override existing resource if they have also been defined in the WCT (as is the case with a few resources).

@michael-hawker michael-hawker modified the milestones: 7.1, 7.2/8.0? Aug 31, 2021
@ghost ghost removed this from the 7.2/8.0? milestone Aug 31, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 An unexpected issue that highlights incorrect behavior build 🔥 good first issue Issues identified as good for first-time contributors help wanted Issues identified as good community contribution opportunities improvements ✨ need more info 📌 open discussion ☎️ question ❔ Issues or PR require more information
Projects
None yet
Development

No branches or pull requests

5 participants