<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="48"/>
<RowDefinition/>
</Grid.RowDefinitions>
<Grid x:Name="AppTitleBar" Background="Transparent">
<!-- Width of the padding columns is set in LayoutMetricsChanged handler. -->
<!-- Using padding columns instead of Margin ensures that the background
paints the area under the caption control buttons (for transparent buttons). -->
<Grid.ColumnDefinitions>
<ColumnDefinition x:Name="LeftPaddingColumn" Width="0"/>
<ColumnDefinition/>
<ColumnDefinition x:Name="RightPaddingColumn" Width="0"/>
</Grid.ColumnDefinitions>
</Grid>
<!-- This control has a higher z-order than AppTitleBar,
so it receives user input. -->
<MenuBar HorizontalAlignment="Left">
<MenuBarItem Title="Item1">
<MenuFlyoutItem Text="Flyout Item1"/>
</MenuBarItem>
</MenuBar>
<AutoSuggestBox QueryIcon="Find"
PlaceholderText="Search"
HorizontalAlignment="Center"
Width="260" Height="32"/>
</Grid>
主页.xaml.cs
public MainPage()
{
this.InitializeComponent();
// Hide default title bar.
CoreApplicationViewTitleBar coreTitleBar =
CoreApplication.GetCurrentView().TitleBar;
coreTitleBar.ExtendViewIntoTitleBar = true;
// Set caption buttons background to transparent.
ApplicationViewTitleBar titleBar =
ApplicationView.GetForCurrentView().TitleBar;
titleBar.ButtonBackgroundColor = Colors.Transparent;
// Set XAML element as a drag region.
Window.Current.SetTitleBar(AppTitleBar);
}
1条答案
按热度按时间vsmadaxz1#
根据docs窗口标题栏定制
必须调用
SetTitleBar
来定义一个区域作为可拖动的标题栏区域。使用
ExtendViewIntoTitleBar = true
隐藏默认的标题栏,您的MenuBar
将显示在标题栏的顶部。主页.xaml
主页.xaml.cs