通用Windows 10 - 如何在Microsoft Edge等标题栏中添加按钮?

时间:2015-07-30 10:17:16

标签: windows win-universal-app

我将Extend View用于标题栏,如下所示:

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

我的Xaml代码是:

 <Page
x:Class="ProjectX.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:ProjectX"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">

<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
    <Grid Background="#263238" Height="32" VerticalAlignment="Top" RequestedTheme="Dark">
        <TextBlock Text="Title Bar" VerticalAlignment="Center" HorizontalAlignment="Center"/>
        <Button Width="50" Height="32" Click="Button_Click"/>
    </Grid>
    <TextBlock x:Name="txtTest" Text="AAAAAAAAAA" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="Black"/>
</Grid>

按钮无法点击。救救我!

2 个答案:

答案 0 :(得分:0)

您可以添加后退按钮

using Windows.UI.Core;
var currentView = SystemNavigationManager.GetForCurrentView();
currentView.AppViewBackButtonVisibility = AppViewBackButtonVisibility.Visible;

答案 1 :(得分:0)

您在此处有完整说明:https://marcominerva.wordpress.com/2015/05/19/easily-manage-the-title-bar-in-windows-10-apps/

简而言之,您错过的是必须调用Window.Current.SetTitleBar方法来设置只有该控件用于处理窗口操作,而其他控件将定期接收输入。