Skip to content

Fix runtime theme resource replacement - #3470

Open
jfversluis wants to merge 1 commit into
mainfrom
jfversluis-verify-issue-3468
Open

Fix runtime theme resource replacement#3470
jfversluis wants to merge 1 commit into
mainfrom
jfversluis-verify-issue-3468

Conversation

@jfversluis

@jfversluis jfversluis commented Aug 13, 2026

Copy link
Copy Markdown
Member

Summary

  • replace MergedDictionaries.Clear() with removal of only the active theme dictionary
  • preserve app-level dictionaries such as Colors.xaml and Styles.xaml
  • instantiate the default theme as a typed dictionary so it can be identified at runtime

Fixes #3468

Verification

The current .NET MAUI app template merges Colors.xaml and Styles.xaml into Application.Resources, so clearing MergedDictionaries removes resources unrelated to the selected theme. The updated example removes only LightTheme or DarkTheme before adding the selected theme.

Upstream references:


Internal previews

File Preview link
docs/user-interface/theming.md docs/user-interface/theming

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
Copilot AI lite review requested due to automatic review settings August 13, 2026 14:45
@jfversluis
jfversluis requested a review from a team as a code owner August 13, 2026 14:45
@learn-build-service-prod

Copy link
Copy Markdown
Contributor

PoliCheck Scan Report

The 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 found

More information about PoliCheck

Information: PoliCheck | Severity Guidance | Term
For any questions: Try searching the learn.microsoft.com contributor guides or post your question in the Learn support channel.

@learn-build-service-prod

Copy link
Copy Markdown
Contributor

Learn Build status updates of commit dc03b4c:

✅ Validation status: passed

File Status Preview URL Details
docs/user-interface/theming.md ✅Succeeded View (>=net-maui-8.0)

For more details, please refer to the build report.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment thread docs/user-interface/theming.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Load a theme at runtime - Codeblock throws exception

2 participants