Windows 10 UWP程序标题栏设置

在Windows 10程序中,以前只能用于全屏方式的Metro程序现在可以运行在窗口模式下了,并且改了个新名字,叫Windows 通用程序(Universal Windows app),简称UWP程序。新的UWP程序虽然大体上还是和以前的Metro程序差不多的,但还是引入了一点新东西的,本文这里就介绍一下它的标题栏设置的几个特性。

 隐藏标题栏:

将应用界面扩展至 Titlebar 区域

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

修改标题栏颜色:

    var tiWtleBar = Windows.UI.ViewManagement.ApplicationView.GetForCurrentView().TitleBar;
    titleBar.BackgroundColor = Colors.DarkBlue;
    titleBar.ForegroundColor = Colors.White;
    titleBar.ButtonHoverBackgroundColor = Colors.LightBlue;
    titleBar.ButtonBackgroundColor = Colors.Maroon;
    titleBar.ButtonForegroundColor = Colors.White;

 

自定义标题栏控件:

可以将界面中任意控件指定为标题栏,指定后该控件将具有标题栏的行为特性,如拖动窗口、右键弹出窗口操作菜单等。

    Window.Current.SetTitleBar(grid);

原文地址:https://www.cnblogs.com/TianFang/p/4732471.html