VisualStateGroups do not update styling when theme has changed

Hi,
in my app I'm using the sfSwitch button from an example of yours. This is the XAML code.

<buttons:SfSwitch
                                                   Grid.Column="2"
                                                   Margin="8,0"
                                                            AllowIndeterminateState="False"
                                                            HeightRequest="28"
                                                            VisualType="Cupertino"
                                                            IsOn="{Binding ApplyTaxes}"
                                                            
                                                            >
                                                            <!-- -->
                                                            <VisualStateManager.VisualStateGroups>
                                                                <VisualStateGroup x:Name="CommonStates">
                                                                    <VisualState x:Name="On">
                                                                        <VisualState.Setters>
                                                                            <Setter Property="SwitchSettings">
                                                                                <Setter.Value>
                                                                                    <buttons:CupertinoSwitchSettings
                                                                                        x:TypeArguments="buttons:OnState"
                                                                                        ThumbBorderColor="{DynamicResource Gray-200}"
                                                                                        ThumbColor="{DynamicResource Gray-White}"
                                                                                        TrackBorderColor="{DynamicResource Gray-200}"
                                                                                        TrackColor="{DynamicResource PrimaryColor}" />
                                                                                </Setter.Value>
                                                                            </Setter>
                                                                        </VisualState.Setters>
                                                                    </VisualState>
                                                                    <VisualState x:Name="Off">
                                                                        <VisualState.Setters>
                                                                            <Setter Property="SwitchSettings">
                                                                                <Setter.Value>
                                                                                    <buttons:CupertinoSwitchSettings
                                                                                        x:TypeArguments="buttons:OffState"
                                                                                        ThumbBorderColor="{DynamicResource Gray-200}"
                                                                                        ThumbColor="{DynamicResource Gray-White}"
                                                                                        TrackBorderColor="{DynamicResource Gray-200}"
                                                                                        TrackColor="{DynamicResource Gray-200}" />
                                                                                </Setter.Value>
                                                                            </Setter>
                                                                        </VisualState.Setters>
                                                                    </VisualState>
                                                                </VisualStateGroup>
                                                            </VisualStateManager.VisualStateGroups>
                                                            
                                                        </buttons:SfSwitch>


My app is using a light and dark theme. The problem is, when I change the theme at runtime (on iOS in my case), the style of the sfSwitch do not change.
However only on the currently open ContentPage. If I visit another page, the style displayed accurately. All other styles are working fine, it's just the sfSwitch control
which has issues. It's also the only control using the VisualStateGroup though.

I also tried to apply the VisualStateGroup in a style, however I saw that this isn't possible with the sfSwitch control.

Please see the screenshots attached.

It seems that the keyword "DynamicResource" seems not to work as aspected.
I'm using this approach to implement dark mode support: https://devblogs.microsoft.com/xamarin/modernizing-ios-apps-dark-mode-xamarin/


Attachment: screenshots_fa447e41.zip

3 Replies

SP Sakthivel Palaniyappan Syncfusion Team July 2, 2020 01:52 PM UTC

Hi Andreas ,

We suspect the issue is related to Xamarin.Forms. We have already faced a similar issue in Xamarin.Forms. And we have reported the same. In that the Theme applied only when moved from one page to another. Could you please check if the issue you have faced is similar,

https://github.com/xamarin/Xamarin.Forms/issues/11193

If the issue differs, could you please provide the additional information of the issue which help us to investigate further on the issue.

Regards,
Sakthivel P.
 



AR Andreas Reitberger July 3, 2020 06:41 AM UTC

Hi Sakthivel,

yes this is the same issue I'm facing. Thanks for submitting a bug report on github about this.
Hopefully this gets fixed soon.

Thank you,
Andreas


SS Suganya Sethuraman Syncfusion Team July 6, 2020 11:16 AM UTC

Hi Andreas, 
 
Thanks for the response. 
 
We will let you once we get the solution from the Xamarin Team. 
 
Please get back to us if you need any further assistance. 
 
Regards, 
Suganya S 
 


Loader.
Up arrow icon