Bil*_*llC 2 hamburger-menu uwp
我正在尝试更改导航视图中汉堡包按钮的颜色。我可以更改 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>
Run Code Online (Sandbox Code Playgroud)
下面修改后的代码解决了该问题
<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>
Run Code Online (Sandbox Code Playgroud)
小智 5
这对我有用
<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>
Run Code Online (Sandbox Code Playgroud)