UWP:NavigationView无法更改面板背景

时间:2019-05-17 07:12:11

标签: uwp uwp-xaml

为了进行测试,我使用的是Xaml-Controls-Gallery来源。但是当我尝试输入

 <SolidColorBrush x:Key="NavigationViewExpandedPaneBackground" Color="Red"/>
 <SolidColorBrush x:Key="NavigationViewDefaultPaneBackground" Color="Red" />

什么都没有改变。仅当我提取XAML代码并更改 SplitView 中的 PaneBackground 属性时。

项目信息:

  • 目标+最小值:1809(17763)
  • Microsoft.UI.Xaml 2.1.190405004.2

1 个答案:

答案 0 :(得分:0)

我测试了NavigationView,并且<SolidColorBrush x:Key="NavigationViewExpandedPaneBackground" Color="Red"/>运作良好,如果您的目标版本和最低版本为1809,则无需将NavigationView Microsoft.UI.Xaml一起使用 nuget程序包。

<Page.Resources>
    <SolidColorBrush x:Key="NavigationViewExpandedPaneBackground" Color="Red"/>
    <SolidColorBrush x:Key="NavigationViewDefaultPaneBackground" Color="Red" />
</Page.Resources>

<Grid>
    <NavigationView x:Name="nvSample">
        <NavigationView.MenuItems>
            <NavigationViewItem Icon="Play" Content="Menu Item1" Tag="SamplePage1" />
            <NavigationViewItem Icon="Save" Content="Menu Item2" Tag="SamplePage2" />
            <NavigationViewItem Icon="Refresh" Content="Menu Item3" Tag="SamplePage3" />
            <NavigationViewItem Icon="Download" Content="Menu Item4" Tag="SamplePage4" />
        </NavigationView.MenuItems>
        <Frame x:Name="contentFrame"/>
    </NavigationView>
</Grid>

enter image description here