If I try to make the arrow image for an expander change with system theme change, it doesn't change. The code below works perfectly, but the arrow image will be impossible to see if the app is in dark mode.
<xct:Expander>
<xct:Expander.Header>
<Grid>
<Label
FontAttributes="Bold"
FontSize="15"
Style="{StaticResource Label}"
Text="More Details" />
<Image
HeightRequest="25"
HorizontalOptions="End"
Source="DownArrow.png"
VerticalOptions="Start">
<Image.Triggers>
<DataTrigger
Binding="{Binding Source={RelativeSource AncestorType={x:Type xct:Expander}}, Path=IsExpanded}"
TargetType="Image"
Value="True">
<Setter Property="Source" Value="UpArrow.png" />
</DataTrigger>
</Image.Triggers>
</Image>
</Grid>
</xct:Expander.Header>
<Label
Text="Some content"
TextColor="{AppThemeBinding Light={StaticResource TextColor},
Dark=LightGray}" />
</xct:Expander>
If I try to make the make the arrow for the expander change with the system theme by doing {AppThemeBinding Light=DownArrow.png,Dark=DownArrowDark.png} and {AppThemeBinding Light=UpArrow.png,Dark=UpArrowDark.png} for image source, the image only changes from a down arrow to an up arrow on the first click then stays as an up arrow and doesn't update.
CodePudding user response:
Rotate the image 180 degrees instead of replacing the source:
<Setter Property="Rotation" Value="180" />