Category / Section
How to set alternative colors for rated SfRatingItems
1 min read
To set alternative colors for rated SfRatingItems use “AlternationCount” property in SfRating. Also in triggers set colors for SfRatingItems using “RatedFill” property depends up on the AlternationIndex of the SfRating.
XAML
<Grid> <Grid.Resources> <Style TargetType="sf:SfRatingItem"> <Style.Triggers> <Trigger Property="sf:SfRating.AlternationIndex" Value="0"> <Setter Property="RatedFill" Value="DeepSkyBlue"> </Setter> </Trigger> <Trigger Property="sf:SfRating.AlternationIndex" Value="1"> <Setter Property="RatedFill" Value="DeepPink"></Setter> </Trigger> </Style.Triggers> </Style> </Grid.Resources> <sf:SfRating HorizontalAlignment="Center" VerticalAlignment="Center" Name="rating" AlternationCount="2" > <sf:SfRatingItem/> <sf:SfRatingItem/> <sf:SfRatingItem/> <sf:SfRatingItem/> <sf:SfRatingItem/> <sf:SfRatingItem/> </sf:SfRating> </Grid>
The following screenshot illustrates the output of the above code example