SfSwitch doesn't update custom colors, when used with the intermediate state.

Hi,

I’m using SfSwitch with a style defined in App.xaml. The colors oft he SfSwitch do not update to the right state. I use the tree states of the control :

<buttons:SfSwitch Grid.Column="1" IsOn="{Binding Relay1}" Style="{StaticResource SwitchStyle}" AllowIndeterminateState="True" HorizontalOptions="Start" VerticalOptions="Center"/>

I use the SfSwitch control in a ListView.

The value of the control is in ViewModel

public bool? Relay1 { get => relay1; set { relay1 = value; OnDataChanged(); } }

The whole List is downloaded at the beginning.

 

 

The style for the control is defined in App.xaml

<Style TargetType="buttons:SfSwitch" x:Key="SwitchStyle">

                <Setter Property="VisualType" Value="Custom" />

                <Setter Property="VisualStateManager.VisualStateGroups">

                    <VisualStateGroupList>

                        <VisualStateGroup  x:Name="CommonStates">

 

                            <VisualState x:Name="On">

                                <VisualState.Setters>

                                    <Setter Property="SwitchSettings">

                                        <Setter.Value>

                                            <buttons:DefaultSwitchSettings x:TypeArguments="buttons:OnState"

                                                        ThumbBorderColor="DarkGreen" ThumbColor="Green"

                                                        TrackBorderColor="DarkGreen" TrackColor="LightGreen"

                                                        BusyIndicatorColor="{StaticResource PrimaryColor}" /> 

                                        </Setter.Value>

                                    </Setter>

                                </VisualState.Setters>

                            </VisualState>

 

                            <VisualState x:Name="Off">

                                <VisualState.Setters>

                                    <Setter Property="SwitchSettings">

                                        <Setter.Value>

                                            <buttons:DefaultSwitchSettings x:TypeArguments="buttons:OffState"

                                                        ThumbBorderColor="DarkGray" ThumbColor="White"

                                                        TrackBorderColor="DarkGray" TrackColor="LightGray"/>

                                        </Setter.Value>

                                    </Setter>

                                </VisualState.Setters>

                            </VisualState>

 

                            <VisualState x:Name="Indeterminate">

                                <VisualState.Setters>

                                    <Setter Property="SwitchSettings">

                                        <Setter.Value>

                                            <buttons:DefaultSwitchSettings x:TypeArguments="buttons:IndeterminateState"

                                                        ThumbBorderColor="DarkBlue" ThumbColor="Blue"

                                                        TrackBorderColor="DarkBlue" TrackColor="LightBlue"/>

                                        </Setter.Value>

                                    </Setter>

                                </VisualState.Setters>

                            </VisualState>

                        </VisualStateGroup>

                    </VisualStateGroupList>

                </Setter>

            </Style>

 

When I use the Xamarin control with two states (true/false) the page works well. With the three states true/false/null the SfSwitch has the problem, that the control schows the wrong colors for the state. Sometimes the colors are Ok, but the state is wrong.

 

Thanks

Marian


4 Replies

SS Suganya Sethuraman Syncfusion Team April 26, 2021 12:47 PM UTC

Hi Marian,

Greetings from Syncfusion.

We are currently validating on this and we will update the details on or before April 28, 2021. We appreciate your patience until then.

Regards,
Suganya Sethuraman.
 



SP Sakthivel Palaniyappan Syncfusion Team April 28, 2021 02:53 PM UTC

Hi Marian,

Thanks for the patience.

We have checked the reported issue and we could be able to reproduce the issue.
Since PanGesture isn't working properly in Android, the issue only occurs when we use SfSwitch in ListView. We'll consult with the Xamarin team and have an update on April 30, 2021. Until then, we value your patience.

Regards,
Sakthivel P.



SP Sakthivel Palaniyappan Syncfusion Team April 30, 2021 02:38 PM UTC

Hi Marian,

Thanks for the patience.

We have checked the reported issue and on further analyses reported issue is related to framework issue. Please find the Xamarin team issue link below.

Issue link: https://github.com/xamarin/Xamarin.Forms/issues/1977

We will check the possibilities to provide workaround and update the details on May 6, 2021.

Regards,
Sakthivel P.


SP Sakthivel Palaniyappan Syncfusion Team May 6, 2021 12:08 PM UTC

Hi Nguyen,

Thanks for the patience.

We investigated the options for meeting your requirements at the sample level, but we are currently unable to address the identified problem at the sample level. If the Xamarin team has resolved the problem, we will notify you.

Regards,
Sakthivel P.


Loader.
Up arrow icon