通用的Windows应用程序全屏按钮 [英] Windows Universal App Fullscreen Button
问题描述
在Windows应用商店一些应用程序有一个全屏按钮附加到最小化,最大化,并在标题栏关闭按钮。该按钮看起来类似于退出全屏按钮,每一个应用程序已经在标题栏,如果全屏处于活动状态。那是一个系统的控制,如果我如何使用它在我的C#通用应用程序?
Some Apps in the Windows Store have a Fullscreen button additional to the minimize, maximize and close button in the Titlebar. This button looks similar to the exit Fullscreen button that every App has in the Titlebar if the Fullscreen is active. Is that a system control and if how can I use it in my C# Universal App?
推荐答案
您将不得不使用的 Window.SetTitleBar
方法来达到你想要的行为。因此,你需要完成以下几个步骤:
You'll have to use the Window.SetTitleBar
method to achieve your desired behavior. Therefore, you'll need to accomplish a few steps:
首先,使视图以延伸到标题栏。请注意,您只能设置标题栏的左侧。在最小化的最大化和关闭的按钮仍然会在那里:
First, enable the view to extend into the title bar. Please note, that you can only set the left part of the title bar. The Minimize, Maximize and Close buttons will still be there:
CoreApplication.GetCurrentView().TitleBar.ExtendViewIntoTitleBar = true;
在您设置,你叫 Window.SetTitleBar
方法与的UIElement
:
After you have set that, you call the Window.SetTitleBar
method with an UIElement
:
Window.Current.SetTitleBar(myTitleBar);
在哪里为 myTitleBar
可能看起来像这样:
<Border x:Name="myTitleBar">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<!-- Title -->
<TextBlock Grid.Column="0"
Text="..."/>
<!-- Custom buttons attached to the right side -->
<StackPanel Grid.Column="1"
Orientation="Horizontal">
<Button x:Name="FullScreenButton"/>
<!-- Use U+E740 FullScreen Icon for the button above -->
</StackPanel>
</Grid>
</Border
由Marco密涅瓦的扩展指南(包括一个不错的XAML的行为,这将更好的调整这个用例)可以发现<一个href=\"https://marcominerva.word$p$pss.com/2015/05/19/easily-manage-the-title-bar-in-windows-10-apps/\"相对=nofollow>这里。
这篇关于通用的Windows应用程序全屏按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!