Skip to content

Switching theme at runtime does not apply to visual states #3388

Closed

Description

@MartinZikmund

Current behavior

When theme is switched at runtime, it does not apply to visual states of controls - for example button pressed.

Expected behavior

New theme should apply everywhere.

When theme

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

Consider the following page content:

<Grid x:Name="Grid" Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
   <Button x:Name="Button">Click</Button>
</Grid>

And make sure App.xaml has no RequestedTheme set:

Application
	x:Class="SamplesApp.App"
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

Run the app on Android in light theme, then switch to dark theme via the action center. Notice the page changes background and button changes its colors. However, when the button is pressed it "disappears" because it still uses the "light" theme of pressed visual state.

Environment

Nuget Package:

Package Version(s):

Affected platform(s):

  • iOS
  • Android
  • WebAssembly
  • WebAssembly renderers for Xamarin.Forms
  • macOS
  • Windows
  • Build tasks
  • Solution Templates

Visual Studio:

  • 2017 (version: )
  • 2019 (version: )
  • for Mac (version: )

Relevant plugins:

  • Resharper (version: )

Anything else we need to know?

Activity

  1. added
    kind/bug
    triage/untriaged
    project/styling 👔
    and removed
    triage/untriaged
    on Jun 17, 2020
  2. MartinZikmund commented on Jun 17, 2020

    @MartinZikmund
    MemberAuthor

    This is probably for @davidjohnoliver 😇

  3. changed the title [-]Swithing theme at runtime does not apply to visual states[/-] [+]Switching theme at runtime does not apply to visual states[/+] on Jun 23, 2020
  4. MartinZikmund commented on Jul 2, 2020

    @MartinZikmund
    MemberAuthor

    Seems that it is not only with visual states - with the Messages sample app (https://github.com/MartinZikmund/messages-multiplatform-uno-sample) I have noticed that changing theme at runtime does not apply new text color to the "Messages" header on the right pane - I think I saw it on Android specifically. Also theme change at runtime on macOS seemed to crash the app, but I have a feeling that is a problem on my side :-D .

    GitHub
    Contribute to MartinZikmund/messages-multiplatform-uno-sample development by creating an account on GitHub.
  5. jeromelaban commented on Jul 2, 2020

    @jeromelaban
    Member

    if you have a stack trace to share, that may help for similar issues.

  6. MartinZikmund commented on Jul 2, 2020

    @MartinZikmund
    MemberAuthor

    I rushed as it was like 2 AM so I did not capture it, but will retry and find it 👍

  7. davidjohnoliver commented on Jul 2, 2020

    @davidjohnoliver
    Contributor

    Seems that it is not only with visual states - with the Messages sample app (https://github.com/MartinZikmund/messages-multiplatform-uno-sample) I have noticed that changing theme at runtime does not apply new text color to the "Messages" header on the right pane - I think I saw it on Android specifically.

    Thanks for the poke Martin! Any idea why that text header might be failing to update? I know I missed the visual-state case, but it seems like there's another case I missed as well.

    GitHub
    Contribute to MartinZikmund/messages-multiplatform-uno-sample development by creating an account on GitHub.
  8. MartinZikmund commented on Jul 2, 2020

    @MartinZikmund
    MemberAuthor

    @davidjohnoliver Really hard to say, I just noticed that while most texts changed, this one didn't unless I restarted the app. I will check again later to confirm if I just didn't miss something.

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

Metadata

Metadata

Labels

kind/bugproject/styling 👔

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions