Skip to content

Load a theme at runtime - Codeblock throws exception #3468

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    resolved-by-customerIndicates issues where the customer no longer needs any help. [org]

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions