Skip to content

The example for updating a Theme resource is incomplete. #1470

Done

Description

@DanTravison

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.

Activity

  1. added
    Pri1
    on May 4, 2023
  2. added
    doc-enhancement
    on Jul 26, 2023
  3. added
    ⌚ Not Triaged
    and removed
    Pri1
    on Jul 26, 2023
  4. jfversluis commented on Nov 27, 2026

    @jfversluis
    Member

    The theming example now removes the current theme dictionary instead of clearing all merged dictionaries. This was addressed by #3470, so I am closing this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions