microsoft / microsoft/microsoft-ui-xaml
Proposal: Non-XAML `ThemeResource`
- Dominant language
- C++
- Stars
- 8.4k
- Forks
- 942
- Avg merge
- 2d 7h
- Merged PRs (30d)
- 105
Description
# Proposal: Non-XAML `ThemeResource`
## Summary
Currently it is only possible to set `ThemeResource` from XAML, which is problematic in various scenarios, for example in Uno Platform's C# Markup:
- https://github.com/unoplatform/uno.extensions/issues/2429
- https://github.com/unoplatform/uno.csharpmarkup/issues/716
This is especially problemtai
## Rationale
* It is not possible to retrieve a theme-dependent brush for a given theme from a `ResourceDictionary` in code
* It is not possible to set a property like `Background` or `BorderBrush` of a control to a theme-dependent brush in code
## Scope
| Capability | Priority |
| :---------- | :------- |
| Retrieve a theme-dependent value of a resource from `ResourceDictionary` in code | Must |
| Set a control's dependency property to a theme-dependent resource in code | Must |
## Workarounds
There some very limited ways to work around this, like: https://github.com/microsoft/microsoft-ui-xaml/blob/66a7b0ae71c19f89c6a7d86a1986794ad1a1bf09/src/controls/dev/WebView2/WebView2.cpp#L909-L927 , but these are very inefficient and definitely not ideal.
Contributor guide
Research direction
Start with docs/feature_proposal_process.md and review the WebView2.cpp workaround linked in the issue. Identify the API and resource-system entry points needed for the two Must capabilities: retrieving theme-dependent values in code and assigning them to control dependency properties. Done means the proposal has an agreed design and implementation scope for both cases.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, csharp
- Domain
- desktop
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100