Hello,
According to your distribution, all selected appearance doesn't work, you could check if you turn on the dark mode (dark theme) on your testing device, and you could respond to system theme changes in MAUI.
Currently, you set Label TextColor="White"
, it is exact value, so the style doesn't work. You can try to remove the setting:
<Label Grid.Row="1"
Text= "Binding Title"
FontSize="Body"
Padding="7,0,7,0"
VerticalTextAlignment="Center"
HorizontalTextAlignment="Center"
x:Name="_label">
</Label>
Besides, Image.Source
should be an image, you set <Setter TargetName="_image" Property="Image.Source" Value="Red" />
, the value is red color, you could try to design two images for different selecting state, or set background color for the image. If you have any other issues about the image, please feel free to post here.
Xaml:
<Image Grid.Row="0"
HeightRequest="40"
Margin="5,0,5,0"
HorizontalOptions="CenterAndExpand"
x:Name="_image"/>
Styles:
<Style x:Key="FloutItemStyle" TargetType="Grid">
<Setter Property="VisualStateManager.VisualStateGroups">
<VisualStateGroupList>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Normal">
<VisualState.Setters>
<Setter Property="BackgroundColor"
Value="Transparent" />
<Setter TargetName="_label" Property="Label.TextColor" Value="{AppThemeBinding Light= Black, Dark=White}" />
<Setter TargetName="_image" Property="Image.Source" Value="{AppThemeBinding Light= unselected.png, Dark= unselected.png}" />
</VisualState.Setters>
</VisualState>
<VisualState x:Name="Selected">
<VisualState.Setters>
<Setter Property="BackgroundColor"
Value="{AppThemeBinding Light= {StaticResource Blue100Accent}, Dark=White}" />// change the bacground , you can remove it if you don't need
<Setter TargetName="_label" Property="Label.TextColor" Value="{AppThemeBinding Light= Red, Dark=White}" />
<Setter TargetName="_image" Property="Image.Source" Value="{AppThemeBinding Light= myicon.jpg, Dark= myicon.jpg}" />
// or set <Setter TargetName="_image" Property="Image.BackgroundColor" Value="{AppThemeBinding Light= Red, Dark= White}" />
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
</VisualStateGroupList>
</Setter>
</Style>
Apply background colour to Flyout (currently it is still default black in NET7)
<Shell
......
FlyoutBackgroundColor="{AppThemeBinding Light=White, Dark={StaticResource Gray200}}"
>
Best Regards,
Wenyan Zhang
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.