C# 如何启动全屏应用程序?

C# 如何启动全屏应用程序?,c#,wpf,xaml,C#,Wpf,Xaml,我发现了一些代码,我想知道是否有人能解释它是如何工作的 <Window x:Class="FullScreenDemo.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:i="clr-namespace:System.

我发现了一些代码,我想知道是否有人能解释它是如何工作的

<Window x:Class="FullScreenDemo.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
        xmlns:Einstein="clr-namespace:FullScreenDemo"
        Title="FullScreenBehavior Demo" Width="640" Height="480"
        Einstein:FullScreenBehavior.IsFullScreen="{Binding Path=IsChecked, ElementName=FullScreenButton, Mode=TwoWay}">

    <i:Interaction.Behaviors>
        <Einstein:FullScreenBehavior
            FullScreenOnDoubleClick="{Binding IsChecked, ElementName=FullOnDoubleClick}"
            FullScreenOnMaximize="{Binding IsChecked, ElementName=FullOnMaximize}"
            RestoreOnEscape="{Binding IsChecked, ElementName=ExitOnEscape}"/>
    </i:Interaction.Behaviors>

    <Viewbox Stretch="Uniform">

        <Grid Width="640" Height="480">

            <StackPanel Margin="20">

                <TextBlock Text="Full Screen Demo" FontSize="32" />

                <TextBlock TextWrapping="Wrap">

                    <LineBreak />
                    <LineBreak />

                    <Run>
                        The FullScreenBehavior makes it easy to create a WPF window that can &quot;go full screen&quot;.
                        By default, the full screen setting can only be changed programmatically. Try pressing the 
                        ToggleButton in the upper right hand corner which is Two-Way bound to the IsFullScreen
                        property of the Window.
                    </Run>

                    <LineBreak />
                    <LineBreak />

                    <Run>
                        This demo uses a ViewBox to scale the content with the Window but that is not required.
                        You can use whatever layout strategy you want.
                    </Run>

                    <LineBreak />
                    <LineBreak />

                    <Run>
                        There are properties that can be set that can be used to enable automatic full screen behavior
                        in response to common user actions. Play around with the options below which control how the
                        Window reacts to user gestures.
                    </Run>

                    <LineBreak />

                </TextBlock>

                <CheckBox x:Name="FullOnMaximize" Margin="5" Content="Maximizing enters full screen"/>
                <CheckBox x:Name="FullOnDoubleClick" Margin="5" Content="Double clicking enters/exits full screen" />
                <CheckBox x:Name="ExitOnEscape" Margin="5" Content="Pressing escape exits full screen"/>

            </StackPanel>

            <ToggleButton x:Name="FullScreenButton" Content="Full Screen"
                          Margin="8" VerticalAlignment="Top" HorizontalAlignment="Right"
                          Height="50" Width="120" Checked="FullScreenButton_Checked"/>

        </Grid>

    </Viewbox>

</Window>

FullScreenBehavior使创建可以“全屏显示”的WPF窗口变得很容易。
默认情况下,只能通过编程方式更改全屏设置。试着按一下按钮
右上角的ToggleButton,双向绑定到IsFullScreen
属性。
此演示使用ViewBox来缩放窗口中的内容,但这不是必需的。
您可以使用任何您想要的布局策略。
可以设置一些属性,用于启用自动全屏行为
响应常见的用户操作。使用下面的选项进行操作,这些选项控制
窗口对用户手势做出反应。
我将代码更新为完整的XAML代码。我最初发布的相关部分,但我张贴的要求,整个代码

我看到没有“代码”使窗口全屏显示。我的问题是它是如何使窗口“全屏”的

我发现了一些代码,我想知道是否有人能解释它是如何工作的

没有人可以,因为你错过了爱因斯坦的行为:全屏行为

行为是定制的XAML元素,您会错过代码——您只需要集成到页面中

它不是关于开始,它做一些按钮和一些事件连接,没有任何东西说窗口开始全屏,除非选中FullscrrenButton_


但要了解它是如何工作的,您需要为我们提供行为的代码。

什么
Einstein
是一个名称空间,
FullScreenBehavior
是一个类。请看它的定义来查看代码。再说一遍,这不是关于XAML代码,而是关于XAML中NT的代码。您在Xaml中使用Einstein:FullScreenBehavior,这是一个.NET类,需要该代码。