Uno: Switching theme at runtime does not apply to visual states

Created on 17 Jun 2020  路  6Comments  路  Source: unoplatform/uno

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):

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

Visual Studio:

  • [ ] 2017 (version: )
  • [x] 2019 (version: )
  • [ ] for Mac (version: )

Relevant plugins:

  • [ ] Resharper (version: )

Anything else we need to know?

kinbug projecstyling

All 6 comments

This is probably for @davidjohnoliver 馃槆

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.

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

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

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.

@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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

MelbourneDeveloper picture MelbourneDeveloper  路  3Comments

jeromelaban picture jeromelaban  路  3Comments

MartinZikmund picture MartinZikmund  路  4Comments

PylotLight picture PylotLight  路  3Comments

jeromelaban picture jeromelaban  路  3Comments