Fix runtime theme resource replacement - #3470
Conversation
Replace clearing all merged dictionaries with removal of only the active theme dictionary. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 669f87da-f7c4-4113-84ba-e2d8e2a693a2
PoliCheck Scan ReportThe following report lists PoliCheck issues in PR files. Before you merge the PR, you must fix all severity-1 and severity-2 issues. The AI Review Details column lists suggestions for either removing or replacing the terms. If you find a false positive result, mention it in a PR comment and include this text: #policheck-false-positive. This feedback helps reduce false positives in future scans. ✅ No issues foundMore information about PoliCheckInformation: PoliCheck | Severity Guidance | Term |
|
Learn Build status updates of commit dc03b4c: ✅ Validation status: passed
For more details, please refer to the build report. |
There was a problem hiding this comment.
Pull request overview
Updates the theming documentation example to avoid clearing all merged resource dictionaries when switching themes at runtime, preventing removal of app-template resources (for example, Colors.xaml and Styles.xaml).
Changes:
- Update the default theme XAML example to instantiate the default theme as a typed dictionary (so it can be identified later).
- Update runtime theme-switching guidance to remove only the active theme dictionary instead of clearing all merged dictionaries.
- Refresh article metadata date.
Show a summary per file
| File | Description |
|---|---|
| docs/user-interface/theming.md | Updates theme resource loading examples to remove only the active theme dictionary and preserve other app-level merged dictionaries. |
Review details
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
- Files reviewed: 1/1 changed files
- Comments generated: 1
- Review effort level: Lite
Summary
MergedDictionaries.Clear()with removal of only the active theme dictionaryColors.xamlandStyles.xamlFixes #3468
Verification
The current .NET MAUI app template merges
Colors.xamlandStyles.xamlintoApplication.Resources, so clearingMergedDictionariesremoves resources unrelated to the selected theme. The updated example removes onlyLightThemeorDarkThemebefore adding the selected theme.Upstream references:
Internal previews