dotnet / dotnet/docs-maui

The example for updating a Theme resource is incomplete.

Open
#1,470 0 comments 0 reactions 0 assignees View on GitHub
doc-enhancement dotnet-maui/tech dotnet-mobile/prod Pri3
Dominant language
No language data
Stars
282
Forks
265
Avg merge
2d 2h
Merged PRs (30d)
19

Description

The example for updating the theme resources at runtime is incomplete. Clearing mergedDictionaries breaks scenarios where other merged resources are being used, such as styles defined in a satellite assembly.

ICollection mergedDictionaries = Application.Current.Resources.MergedDictionaries;
if (mergedDictionaries != null)
{
mergedDictionaries.Clear(); <--- This clears 'all' merged entries, not just the previous theme dictionary.
mergedDictionaries.Add(new DarkTheme());
}

---
#### Document Details

⚠ *Do not edit this section. It is required for learn.microsoft.com ➟ GitHub issue linking.*

* ID: 04d29bb3-0ea9-e42a-d6d2-cf338baca362
* Version Independent ID: 04d29bb3-0ea9-e42a-d6d2-cf338baca362
* Content: [Theme an app - .NET MAUI](https://learn.microsoft.com/en-us/dotnet/maui/user-interface/theming?view=net-maui-7.0)
* Content Source: [docs/user-interface/theming.md](https://github.com/dotnet/docs-maui/blob/main/docs/user-interface/theming.md)
* Product: **dotnet-mobile**
* Technology: **dotnet-maui**
* GitHub Login: @davidbritch
* Microsoft Alias: **dabritch**

Contributor guide

Open the contributing guide

Research direction

Open docs/user-interface/theming.md and find the runtime theme-resource update example linked in the issue. Review how the example handles Application.Current.Resources.MergedDictionaries; done means the documented update no longer removes unrelated merged resources, including resources from a satellite assembly.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
documentation
Issue type
Documentation
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.