UWP NavigationView 更改标题栏背景

UWP NavigationView changes titlebar background

我在 UWP 上使用 WinUI 2.7,在我的 XAML 上我有以下代码:

<Grid Background="{ThemeResource AcrylicBackgroundFillColorDefaultBrush}" ColumnSpacing="10.0">

    <muxc:NavigationView
        x:Name="NavigationView"
        HorizontalContentAlignment="Left"
        IsBackButtonVisible="Collapsed"
        PaneDisplayMode="LeftMinimal"
        SelectionChanged="SelectionChanged">
        <muxc:NavigationView.MenuItems>
            <muxc:NavigationViewItem
                Content="Main Page"
                Icon="Home"
                Tag="MainPage" />
        </muxc:NavigationView.MenuItems>

        <Frame x:Name="MainFrame" Margin="0,0,0,0" />

    </muxc:NavigationView>


</Grid>

在我的 C# 上,我有这段代码可以使标题栏透明

public MainPage()
    {
        this.InitializeComponent();

        var coreTitleBar = CoreApplication.GetCurrentView().TitleBar; 
        coreTitleBar.ExtendViewIntoTitleBar = true;

        var view = Windows.UI.ViewManagement.ApplicationView.GetForCurrentView(); 
        view.TitleBar.ButtonBackgroundColor = Windows.UI.Colors.Transparent;
        view.TitleBar.ButtonInactiveBackgroundColor = Windows.UI.Colors.Transparent;

        
    }

这里的问题是,如果启用了NavigationView,Titlebar和页面的内容会有细微的差别color

但是如果我注释掉 NavigationView,这是 fixed

我发现更改标题栏颜色的唯一方法是使用 NavigationView 的背景属性,但即使通过设置 {ThemeResource AcrylicBackgroundFillColorDefaultBrush} 我也无法使其与其余部分具有相同的颜色第

有没有办法让所有内容的背景颜色完全相同?

请参考这个document, NavigationView contains IsTitleBarAutoPaddingEnabled property, you could set it as false to extend full NavigationView into title bar. For more detail please refer to this document

<muxc:NavigationView IsTitleBarAutoPaddingEnabled="False"/>