Skip to content

ThemeService sets RequestedTheme on XamlRoot's content instead of its own root element (breaks theme switching when hosted in foreign XamlRoot / ALC) #3120

Closed

Description

@vatsashah45

Current behavior

Uno.Extensions.Toolkit.ThemeService (consumed via UseThemeSwitching / IThemeService, registered as ScopedThemeService) applies the theme to RootElement.XamlRoot.Content rather than to RootElement itself. When an app's content is hosted under a XamlRoot it doesn't own — e.g. a secondary app loaded into a collectible AssemblyLoadContext whose Window.Content is re-parented into a host's single shared XamlRoot — the theme is applied to the host's root visual instead of the app's. Toggling the theme re-themes the host while the hosted app does not change.

Expected behavior

When theme switching is toggled via IThemeService.SetThemeAsync(...), the hosted app's theme should change, and ThemeChanged should fire correctly. The behavior should be consistent whether the app is standalone or hosted under a foreign XamlRoot.

How to reproduce it (as minimally and precisely as possible)

  1. App registers theme switching (UseThemeSwitching()), with a light/dark toggle calling IThemeService.SetThemeAsync(...).
  2. Run the app hosted inside another app's XamlRoot — a secondary-app/ALC scenario where the inner app's Window.Content is mounted into a host's XamlRoot.
  3. Toggle the theme.

Expected: the hosted app re-themes.
Actual: the host re-themes; the hosted app does not. ThemeChanged also fails to fire.

Note: Standalone apps are unaffected because there window.Content == XamlRoot.Content, so the bug is invisible.

Activity

  1. self-assigned this
    on Jun 29, 2026
  2. added
    kind/bug
    on Jun 29, 2026
  3. added 6 commits that reference this issue on Jun 29, 2026
    7d271ee
    a425aa9
    a8e6f55
    d2a0a00
    9b3b550
    78688cb
  4. added theissue type on Aug 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

kind/bug

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions