Skip to content

Switch is invisible on PointOver when theme has changed #31819

@AndreasReitberger

Description

@AndreasReitberger

Description

When hovering the Switch control with the mouse, it goes invisible on Windows when the theme was switched at runtime.

Light => Dark: Switch is invisible on Dark Mode
Dark => Light: Switch is invisible on Light Mode

At the repro repository, you will find 3 projects.

  • SharedMauiXamlStylesLibrary => All styles for core controls, like the switch (Resources\Themes\Controls\Switch.xaml)
  • SharedMauiXamlStylesLibrary.Syncfusion (not relevant for this bug)
  • SharedMauiXamlStylesLibrary.SampleApp

This is the setup for the StateGroups.

            <VisualStateGroupList>
                <VisualStateGroup x:Name="CommonStates">
                    <VisualState x:Name="Normal" />
                    <!--
                    <VisualState x:Name="PointOver">
                        <VisualState.Setters>
                        <Setter Property="OnColor" Value="{AppThemeBinding Light={StaticResource Gray300}, Dark={StaticResource Gray700}}" />
                            <Setter Property="ThumbColor" Value="{AppThemeBinding Light={StaticResource Gray300}, Dark={StaticResource Gray700}}" />
                        </VisualState.Setters>
                    </VisualState>
                    -->
                    <VisualState x:Name="Disabled">
                        <VisualState.Setters>
                            <Setter Property="OnColor" Value="{AppThemeBinding Light={StaticResource Gray300}, Dark={StaticResource Gray600}}" />
                            <Setter Property="ThumbColor" Value="{AppThemeBinding Light={StaticResource Gray300}, Dark={StaticResource Gray600}}" />
                        </VisualState.Setters>
                    </VisualState>
                    <VisualState x:Name="On">
                        <VisualState.Setters>
                            <Setter Property="OnColor" Value="{OnPlatform Android={DynamicResource PrimaryColorLight}, Default={AppThemeBinding Light={StaticResource LightGreen}, Dark={StaticResource LightGreen}}}" />
                            <Setter Property="ThumbColor" Value="{OnPlatform Android={DynamicResource PrimaryColor}, Default={StaticResource White}}" />
                        </VisualState.Setters>
                    </VisualState>
                    <VisualState x:Name="Off">
                        <VisualState.Setters>
                            <Setter Property="ThumbColor" Value="{StaticResource White}" />
                            <Setter Property="OnColor" Value="{AppThemeBinding Light={StaticResource Gray300}, Dark={StaticResource Gray700}}" />
                        </VisualState.Setters>
                    </VisualState>
                </VisualStateGroup>
            </VisualStateGroupList>

Steps to Reproduce

  1. Clone this repository: https://github.com/AndreasReitberger/SharedMauiXamlStyles
  2. Run the "x.SampleApp" projcet in the solution for Windows
  3. At the main menu, visit the Switches page
  4. Hover the mouse over the switch control, see everything is ok.
  5. At the main menu, toggle the theme once
  6. Then hover the mouse again, see the control vanish on PointOver
Image While mouse is hovering: Image

With a Background not equal to White, you can see that the control gets White on hovering.

Image

Link to public reproduction project repository

https://github.com/AndreasReitberger/SharedMauiXamlStyles

Version with bug

9.0.110 SR11

Is this a regression from previous behavior?

Not sure, did not test other versions

Last version that worked well

Unknown/Other

Affected platforms

Windows

Affected platform versions

No response

Did you find any workaround?

Not yet

Relevant log output

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions