UWP 程序标题栏设置

我们可以通过两种方式获取不同的标题栏对象,不同对象操作侧重点不同。

var coreTitleBar = Windows.ApplicationModel.Core.CoreApplication.GetCurrentView().TitleBar;

这种方式获取的是一个CoreApplicationViewTitleBar对象,主要控制标题栏扩展等相关功能。后面的coreTitleBar指的就是这个对象。

var appTitleBar = Windows.UI.ViewManagement.ApplicationView.GetForCurrentView().TitleBar;

这种方式获取的是一个ApplicationViewTitleBar对象,主要用于控制标题栏背景色,最小化、最大化、关闭等按钮的颜色、背景色等。后面的appTitleBar指的就是这个对象。

我们自定义标题栏时这两个对象都会用到。  http://www.cnblogs.com/durow/p/4897773.html

 

隐藏标题栏:将应用界面扩展至 Titlebar 区域  

 

[csharp] view plain copy
 
 print?在CODE上查看代码片派生到我的代码片
  1. CoreApplication.GetCurrentView().TitleBar.ExtendViewIntoTitleBar = true;  

 

修改标题栏颜色:

 

[csharp] view plain copy
 
 print?在CODE上查看代码片派生到我的代码片
    1. var view = ApplicationView.GetForCurrentView();  
    2.   
    3.  // active  
    4.  view.TitleBar.BackgroundColor = Color.FromArgb(255, 8, 87, 180);  
    5.  view.TitleBar.ForegroundColor = Colors.White;  
    6.   
    7.  // inactive  
    8.  view.TitleBar.InactiveBackgroundColor = Color.FromArgb(255, 8, 87, 180);  
    9.  view.TitleBar.InactiveForegroundColor = Colors.Black;  
    10.   
    11.  // button  
    12.  view.TitleBar.ButtonBackgroundColor = Color.FromArgb(255, 8, 87, 180);  
    13.  view.TitleBar.ButtonForegroundColor = Colors.White;  
    14.   
    15.  view.TitleBar.ButtonHoverBackgroundColor = Colors.Blue;  
    16.  view.TitleBar.ButtonHoverForegroundColor = Colors.White;  
    17.   
    18.  view.TitleBar.ButtonPressedBackgroundColor = Colors.Blue;  
    19.  view.TitleBar.ButtonPressedForegroundColor = Colors.White;  
    20.   
    21.  view.TitleBar.ButtonInactiveBackgroundColor = Colors.DarkGray;  
    22.  view.TitleBar.ButtonInactiveForegroundColor = Colors.Gray;  
posted @ 2016-09-28 20:25  天涯海角路  阅读(204)  评论(0)    收藏  举报