2013-01-16 144 views
2

我發現了一些代碼,我在想如果有人能解釋它是如何工作的。如何啓動全屏應用程序?

<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> 

我將代碼更新爲FULL XAML代碼。我最初發布了相關部分,但是我應要求發佈了整個代碼。

我看到沒有「代碼」使窗口FullScreen。我的問題是如何使窗口「全屏」?

+3

什麼? 「愛因斯坦」是一個名字空間,「FullScreenBehavior」是一個類。看看這個代碼的定義。 –

回答

2

我發現一些代碼,我想知道,如果有人可以解釋它是如何工作

沒有人可以因爲你錯過行爲獻給愛因斯坦:: FullScreenBehavior

行爲是定製XAML元素和你錯過了代碼 - 你只有集成到頁面中。

這不是關於開始,它做了一些按鈕和一些事件連接,沒有說窗口開始全屏幕除非FullscrrenButton_Checked被選中。

但要查看它的工作原理,您需要爲我們提供行爲代碼。

+0

我用完整的XAML代碼更新了代碼 –

+0

再次 - 這不是關於XAML代碼,而是關於您在xaml中具有NT的代碼。你使用愛因斯坦:Xaml中的FullScreenBehavior,這是一個.NET類,並且需要代碼。 – TomTom

相關問題