英文:
xaml maui - how to change the color of the tab selector of a flyout menu?
问题
I'll provide translations for the code parts you've shared:
DATA TEMPLATE
<DataTemplate>
<Grid Style="{StaticResource FlyoutItemStyle}" WidthRequest="280" ColumnDefinitions="Auto, *"
Padding="0, 10, 0, 10">
<Image Source="{Binding FlyoutIcon}"
Margin="10"
VerticalOptions="Center"
HorizontalOptions="Center"
HeightRequest="38"
WidthRequest="38" />
<Label Grid.Column="1"
Text="{Binding Title}"
FontSize="12"
HorizontalOptions="StartAndExpand"
VerticalOptions="Center"
x:Name="_label">
<Label.Style>
<Style TargetType="Label">
<Setter Property="TextColor" Value="{StaticResource AusDx_Gold}" />
<Style.Triggers>
<DataTrigger TargetType="Label" Binding="{Binding IsEnabled}" Value="False">
<Setter Property="TextColor" Value="{StaticResource AusDx_Blue}" />
</DataTrigger>
</Style.Triggers>
</Style>
</Label.Style>
</Label>
</Grid>
</DataTemplate>
STYLES
<Style x:Key="FlyoutItemStyle" TargetType="Grid">
<Setter Property="VisualStateManager.VisualStateGroups">
<VisualStateGroupList>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Normal" />
<VisualState x:Name="Selected">
<VisualState.Setters>
<Setter Property="BackgroundColor" Value="LightGray"/>
<Setter TargetName="_label" Property="Label.TextColor" Value="Black" />
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
</VisualStateGroupList>
</Setter>
</Style>
Please note that I've only translated the code portions as requested. If you need any further assistance or have specific questions, feel free to ask.
英文:
not sure what the element is actually called so open to changes to the question.
I want to change the color of whatever this is called. I've included the code for my DataTemplate as well as my styles for the menu as I assume its something to do with those.
DATA TEMPLATE
<DataTemplate>
<Grid Style="{StaticResource FlyoutItemStyle}" WidthRequest="280" ColumnDefinitions="Auto, *" Padding="0, 10, 0, 10">
<Image Source="{Binding FlyoutIcon}"
Margin="10"
VerticalOptions="Center"
HorizontalOptions="Center"
HeightRequest="38"
WidthRequest="38" />
<Label Grid.Column="1"
Text="{Binding Title}"
FontSize="12"
HorizontalOptions="StartAndExpand"
VerticalOptions="Center"
x:Name="_label">
<Label.Style>
<Style TargetType="Label">
<Setter Property="TextColor" Value="{StaticResource AusDx_Gold}" />
<Style.Triggers>
<DataTrigger TargetType="Label" Binding="{Binding IsEnabled}" Value="False">
<Setter Property="TextColor" Value="{StaticResource AusDx_Blue}" />
</DataTrigger>
</Style.Triggers>
</Style>
</Label.Style>
</Label>
</Grid>
</DataTemplate>
STYLES
<Style x:Key="FlyoutItemStyle" TargetType="Grid">
<Setter Property="VisualStateManager.VisualStateGroups">
<VisualStateGroupList>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Normal" />
<VisualState x:Name="Selected">
<VisualState.Setters>
<Setter Property="BackgroundColor" Value="LightGray"/>
<Setter TargetName="_label" Property="Label.TextColor" Value="Black" />
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
</VisualStateGroupList>
</Setter>
</Style>
Any help or guidance is greatly appreciated!
答案1
得分: 1
这个选择选项卡可以在Windows的App.xaml中的maui中进行更改。
你可以将这段代码添加到Platforms->Windows->App.xaml文件中。
<maui:MauiWinUIApplication.Resources>
<StaticResource x:Key="NavigationViewSelectionIndicatorForeground" ResourceKey="SystemControlForegroundAccentBrush" />
<SolidColorBrush x:Key="SystemControlForegroundAccentBrush" Color="Red" />
</maui:MauiWinUIApplication.Resources>
要查看更多样式,请参阅WinUI源代码CommonStyles。
英文:
This select tab can be changed in the maui in windows/App.xaml.
You can add this code to Platforms->Windows-> App.xaml file.
<maui:MauiWinUIApplication.Resources>
<StaticResource x:Key="NavigationViewSelectionIndicatorForeground" ResourceKey="SystemControlForegroundAccentBrush" />
<SolidColorBrush x:Key="SystemControlForegroundAccentBrush" Color="Red" />
</maui:MauiWinUIApplication.Resources>
For more styles, you can see the WinUI source code CommonStyles.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论