gpt4 book ai didi

uwp - 如何更改 UWP NavigationView 中 PaneToggleButton 的颜色?

转载 作者:行者123 更新时间:2023-12-05 09:15:26 28 4
gpt4 key购买 nike

我正在尝试更改 NavigationView 中汉堡包按钮的颜色。我可以更改 NavigationViewItems 和按钮的颜色,但下面的代码不会更改 PaneToggleButton。

<Page.Resources>
<Style TargetType="controls:NavigationViewItem">
<Setter Property="Foreground" Value="White"/>
</Style>
<Style TargetType="Button">
<Setter Property="Foreground" Value="White"/>
</Style>
</Page.Resources>

修改下面的代码修复了问题

 <controls:NavigationView.Resources>
<SolidColorBrush x:Key="NavigationViewItemForeground" Color="White"/>
<SolidColorBrush x:Key="NavigationViewItemForegroundPointerOver"Color="Yellow"/>
<SolidColorBrush x:Key="NavigationViewItemForegroundPressed"Color="LightGreen"/>
<SolidColorBrush x:Key="NavigationViewItemForegroundSelected"Color="White"/>
<SolidColorBrush x:Key="NavigationViewItemForegroundSelectedPointerOver" Color="Orange"/>
<SolidColorBrush x:Key="NavigationViewItemForegroundSelectedPressed" Color="Pink"/>
</controls:NavigationView.Resources>

<controls:NavigationView.PaneToggleButtonStyle>
<Style TargetType="Button" BasedOn="{StaticResource PaneToggleButtonStyle}">
<Setter Property="Foreground" Value="White"/>
</Style>
</controls:NavigationView.PaneToggleButtonStyle>

最佳答案

这对我有用

<Page.Resources>
<Style x:Key="CustomNavigationMenuStyle" TargetType="Button" BasedOn="{StaticResource PaneToggleButtonStyle}">
<Setter Property="Foreground" Value="#C21334" />
</Style>
</Page.Resources>

<NavigationView x:Name="nvMainLevelNavigation"
PaneDisplayMode="LeftMinimal"
IsSettingsVisible="false"
Header="Title"
PaneToggleButtonStyle="{StaticResource CustomNavigationIconStyle}"
ItemInvoked="nvMainLevelNavigation_ItemInvoked"
SelectionChanged="nvMainLevelNavigation_SelectionChanged"
Loaded="nvMainLevelNavigation_Loaded">
</NavigationView>

关于uwp - 如何更改 UWP NavigationView 中 PaneToggleButton 的颜色?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52502767/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com