Skip to content

Load a theme at runtime - Codeblock throws exception #3468

Closed

Description

@funnelshift

Type of issue

Outdated article

Description

By following this codeblock, this will result into an exception (Android.Runtime.JavaProxyThrowable).
The codeblock shows you only the remove ALL merged dictionaries, which means also the dictionaries MAUI needs and than add your own.
This means that you need to copy all the contents of Styles.xaml and Colors.xaml and put that into your own ResourceDictionary.
MAUI has two ResourceDictionaries and when those are removed the app just crashes.
A better approach would be to use .Remove(MyTheme) instead of .Clear().

Page URL

https://learn.microsoft.com/en-us/dotnet/maui/user-interface/theming?view=net-maui-11.0#consume-theme-resources

Content source URL

https://github.com/dotnet/docs-maui/blob/main/docs/user-interface/theming.md

Document Version Independent Id

04d29bb3-0ea9-e42a-d6d2-cf338baca362

Platform Id

321f7c7a-4f7e-1852-0cd1-22dd46f55484

Article author

@davidortinau

Metadata

  • ID: 04d29bb3-0ea9-e42a-d6d2-cf338baca362
  • PlatformId: 321f7c7a-4f7e-1852-0cd1-22dd46f55484
  • Service: dotnet-mobile-development
  • Sub-service: dotnet-maui

Related Issues

Activity

  1. jfversluis commented on Aug 13, 2026

    @jfversluis
    Member

    @funnelshift I opened #3470 with a proposed fix that removes only the active theme dictionary instead of clearing all merged dictionaries. Could you confirm whether this is sufficient for the scenario you reported?

  2. funnelshift commented on Aug 13, 2026

    @funnelshift
    Author

    @jfversluis I looked through it and looks good to me. I'll close this one up.

  3. added
    resolved-by-customer
    and removed
    ⌚ Not Triaged
    on Aug 13, 2026
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

    resolved-by-customer

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions