Repository navigation
feat: Lazy theme resource evaluation - #22887
Conversation
There was a problem hiding this comment.
Pull request overview
This PR introduces a WinUI-aligned “pinned dictionary” approach for {ThemeResource} so theme changes can re-resolve resources without repeatedly walking the visual tree, and adds test/sample coverage for element-level theming scenarios.
Changes:
- Add
ThemeResourceReference+ThemeResourceMapto store per-property theme bindings and refresh them efficiently during theme changes. - Extend
ResourceDictionary/ResourceResolverlookups to return the “providing dictionary” so theme bindings can pin the correct dictionary. - Add runtime tests and a manual sample page to validate element-level theme correctness in common control visual states.
Reviewed changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/Uno.UI/UI/Xaml/VisualStateGroup.cs | Adjusts explanatory comments around theme push behavior. |
| src/Uno.UI/UI/Xaml/ThemeWalkResourceCache.cs | Adds per-theme-walk cache to reduce repeated lookups during a theme walk. |
| src/Uno.UI/UI/Xaml/ThemeResourceMap.cs | Adds per-DO storage mapping (DP, precedence) → ThemeResourceReference. |
| src/Uno.UI/UI/Xaml/Setter.cs | Adds optional ThemeResourceReference handling paths in setters. |
| src/Uno.UI/UI/Xaml/ResourceResolver.cs | Introduces pinned-dictionary theme binding registration + providing-dictionary retrieval. |
| src/Uno.UI/UI/Xaml/ResourceDictionary.cs | Adds TryGetValue overload that returns the providing dictionary (for pinning). |
| src/Uno.UI/UI/Xaml/FrameworkElement.Theming.cs | Updates comments clarifying why theme push/pop remains necessary. |
| src/Uno.UI/UI/Xaml/DependencyObjectStore.cs | Adds theme binding storage + “phase 1” pinned refresh before tree-walk updates. |
| src/Uno.UI/UI/Xaml/Data/ThemeResourceReference.cs | New type representing a pinned theme resource binding with refresh logic. |
| src/Uno.UI/UI/Xaml/Data/BindingHelper.cs | Updates comments on when theme context push is required. |
| src/Uno.UI/Helpers/Xaml/SetterExtensions.cs | Adjusts update-reason handling and comments for style setter theme resources. |
| src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml/Given_ElementTheme.cs | Adds regression tests for dark-themed CheckBox visual states/resources. |
| src/SamplesApp/UITests.Shared/Windows_UI_Xaml/ThemeResources/ElementLevelTheme.xaml(.cs) | Adds a manual sample page showcasing nested RequestedTheme behavior. |
| src/SamplesApp/UITests.Shared/UITests.Shared.projitems | Registers the new sample page in the shared project items. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-22887/wasm-skia-net9/index.html |
1 similar comment
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-22887/wasm-skia-net9/index.html |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 19 out of 19 changed files in this pull request and generated 5 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-22887/wasm-skia-net9/index.html |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 20 out of 20 changed files in this pull request and generated 5 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-22887/wasm-skia-net9/index.html |
|
|
04bf3f0 to
2cb36b4
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 20 out of 20 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-22887/wasm-skia-net9/index.html |
|
|
Code reviewFocus: theme resource resolution logic and performance, cross-referenced against WinUI C++ sources. Found 3 issues:
uno/src/Uno.UI/UI/Xaml/ResourceResolver.cs Lines 405 to 417 in 2cb36b4
uno/src/Uno.UI/UI/Xaml/Media/Animation/ObjectAnimationUsingKeyFrames.cs Lines 245 to 262 in 2cb36b4
uno/src/Uno.UI/UI/Xaml/ResourceResolver.cs Lines 318 to 333 in 2cb36b4 uno/src/Uno.UI/UI/Xaml/DependencyObjectStore.Theming.cs Lines 398 to 436 in 2cb36b4 🤖 Generated with Claude Code - If this code review was useful, please react with 👍. Otherwise, react with 👎. |
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-22887/wasm-skia-net9/index.html |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 20 out of 20 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-22887/wasm-skia-net9/index.html |
1 similar comment
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-22887/wasm-skia-net9/index.html |
|
|
|
The build 205625 found UI Test snapshots differences: Details
|
|
|
|
The build 205625 found UI Test snapshots differences: Details
|
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-22887/wasm-skia-net9/index.html |
|
The build 205761 found UI Test snapshots differences: Details
|
|
The build 205761 found UI Test snapshots differences: Details
|
|
|
|
The build 205761 found UI Test snapshots differences: Details
|
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 23 out of 23 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-22887/wasm-skia-net9/index.html |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 23 out of 23 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-22887/wasm-skia-net9/index.html |
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-22887/wasm-skia-net9/index.html |
|
The build 205841 found UI Test snapshots differences: Details
|
|
The build 205841 found UI Test snapshots differences: Details
|
PR Type: ✨ Feature
closes #19381
What is the current behavior?
Theme resource (
{ThemeResource ...}) resolution re-walks the visual tree on every theme change for every element, which is expensive for complex UI trees with many themed controls.What is the new behavior?
Implements lazy theme resource evaluation matching WinUI's CThemeResource pattern:
PR Checklist ✅
Screenshots Compare Test Runresults