2013-05-31 27 views
1

因此,我正在爲窗口打開動畫,並且該動畫看起來非常適合我要做的事情,除了一個關鍵部分...窗口之間的空間和它目前在動畫中是黑匣子。動畫WPF的黑匣子

我google了很多,但我沒有看到這個問題提到任何地方!

我已經在標準窗口中嘗試過這一點,除了黑盒子之外沒有其他區別只顯示在窗口邊框內。除了Visual Studio爲我生成的任何內容之外,我沒有任何代碼隱藏。

這裏是我的窗口:

<Controls:MetroWindow x:Class="Schedule.MainWindow" 
    xmlns:Controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Name="mainWindow" 
    Title="MainWindow" Height="350" Width="525" WindowStartupLocation="CenterScreen"> 

<Window.Resources> 
    <ResourceDictionary> 
     <ResourceDictionary.MergedDictionaries> 
      <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Colours.xaml" /> 
      <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Fonts.xaml" /> 
      <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.xaml" /> 
      <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/Blue.xaml" /> 
      <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/BaseLight.xaml" /> 
     </ResourceDictionary.MergedDictionaries> 
    </ResourceDictionary> 
</Window.Resources> 

<Window.RenderTransform> 
    <ScaleTransform ScaleX="1" ScaleY="1" x:Name="winTransform1"/> 
</Window.RenderTransform> 

<Window.RenderTransformOrigin> 
    <Point X=".5" Y=".5"/> 
</Window.RenderTransformOrigin> 

<Window.Triggers> 
    <EventTrigger SourceName="mainWindow" RoutedEvent="Window.Loaded"> 
     <BeginStoryboard Name="openBoard"> 
      <Storyboard> 
       <DoubleAnimation Storyboard.TargetName="winTransform1" Storyboard.TargetProperty="ScaleX" 
           From="0" To="1" Duration="0:0:1"/> 
      </Storyboard> 
     </BeginStoryboard> 
    </EventTrigger> 
</Window.Triggers> 

<Grid> 

</Grid> 

回答

2

您需要設置Windows AllowsTransparency屬性爲true,所以你沒有得到的黑色背景。

Title="MainWindow" Height="350" Width="525" AllowsTransparency="True" WindowStyle="None" > 

然而AllowsTransparency僅適用於WindowStyle.None這樣你就失去了默認的窗口邊界爲您的應用程序,我不認爲這是周圍的另一種方式,但你可以很容易地接近一個自定義窗口樣式/最小化等按鈕

+0

你太棒了!另外,我很方便地將它轉換爲使用WPF的Modern UI,並且即使在WindowStyle爲None時,它也會繼續處理窗口邊框。 – malexdev