在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);