Windows 通用应用全屏按钮 [英] Windows Universal App Fullscreen Button

查看:27
本文介绍了Windows 通用应用全屏按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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;

设置好之后,使用 UIElement 调用 Window.SetTitleBar 方法:

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 Minerva 的扩展指南(包括一个很好的 XAML 行为,可以更好地调整这个用例)此处.

An extended guide by Marco Minerva (including a nice XAML behavior that will tweak this use-case even better) can be found here.

这篇关于Windows 通用应用全屏按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆