我在 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 和頁面內容的
但是如果我注釋掉 NavigationView,這是
我發現更改標題欄顏色的唯一方法是使用 NavigationView 的背景屬性,但即使設定 {ThemeResource AcrylicBackgroundFillColorDefaultBrush} 我也無法讓它與頁面的其余部分具有相同的顏色

有沒有辦法讓所有東西都擁有完全相同的背景顏色?
uj5u.com熱心網友回復:
請參閱此檔案, NavigationView包含 IsTitleBarAutoPaddingEnabled 屬性,您可以將其設定為 false 以擴展NavigationView到標題欄。有關更多詳細資訊,請參閱此檔案。
<muxc:NavigationView IsTitleBarAutoPaddingEnabled="False"/>
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/313985.html
