-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Description
Description
I have a Switch in a Grid within a DataTemplate of a CollectionView with my own ThumbColor defined like in the example below:
<CollectionView.ItemTemplate>
<DataTemplate x:DataType="{x:Type databaseModels:Band}">
<Grid ColumnDefinitions="*, Auto" RowDefinitions="Auto" Padding="{OnPlatform Default='5, 0, 5, 0', iOS='5, 0, 5, 15'}">
<Label Grid.Row="0" Grid.Column="0" Text="{Binding Band.Name}" VerticalOptions="Center" />
<Switch Grid.Row="0" Grid.Column="1" IsEnabled="True" IsToggled="{Binding IsSelected, Mode=TwoWay}" ThumbColor="{StaticResource Gray100}" OnColor="{StaticResource Orange}" VerticalOptions="Center" HorizontalOptions="Center" Margin="{OnPlatform Android='0, -5, 0, -5'}"/>
</Grid>
</DataTemplate>
</CollectionView.ItemTemplate>Initially the Switch looks like below:
First of all, when the Switch is toggled, it gets its defined wrong OnColor (should be Orange):
After that when it is toggled off again, the defined ThumbColor="{StaticResource Gray100}" is not set back and the Switch looks as follows:
Steps to Reproduce
- Define a ThumbColor and an OnColor for a Switch
- See how the Color looks like when the Switch is not toggled initially
- Toggle the Switch and it will apply the wrong OnColor (should be Orange)
- Toggled again to state "Off" and it will not apply the defined ThumbColor again
In the linked example Project from repository:
- Launch project
- Click on the DotNetBot Icon
- Defined ThumbColor is visible
- Toggle switch on and color does not change to correct OnColor (should be Orange)
- Toggle switch off and color is changed to a system default color, but not the specified ThumbColor again
Hint: The View containing the Switch with the ThumbColor and OnColor is in ..\Pages\Views*BottomSheetContentView.xaml*
Link to public reproduction project repository
Version with bug
8.0.6-nightly.9863
Is this a regression from previous behavior?
No, this is something new
Last version that worked well
7.0.101
Affected platforms
iOS, Android
Affected platform versions
No response
Did you find any workaround?
By the time this issue was reported, I did not find a workaround.
On April 13th 2024, I found the simples way that solved it for me, by just using a CustomSwitch that derived from Switch and use this in my XAML which fixed it for me as you can see below.
Relevant log output
No response


