2012-06-10 24 views
0

我目前工作的項目,該項目結合了emgu CV(圖像處理)和WPF(2D/3D重建)..WPF動畫不能正常工作在Windows形式

該項目首先是建立在Windows窗體中,直到我找到如果我想構建2D/3D對象,我必須使用WPF控件(比如視口3D),它將被覆蓋在圖像幀/捕捉的頂部...所以,我用usercontrol來主機WPF控件在Windows窗體和代碼運行成功... http://i.imgur.com/F9O7i.png

但是,當我試圖做一個簡單的imation(如矩形背景顏色變成另一種顏色等),它不工作..

任何想法如何解決這個問題? http://i.imgur.com/2ZCph.png

回答

0
<Window 
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
x:Class="WpfApplication1.MainWindow" 
x:Name="Window" 
Title="MainWindow" 
Width="640" Height="480"> 
<Window.Resources> 
    <Storyboard x:Key="simple_animation"> 
     <ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Shape.Fill).(SolidColorBrush.Color)" Storyboard.TargetName="rectangle"> 
      <EasingColorKeyFrame KeyTime="0" Value="#FF21AB49"/> 
      <EasingColorKeyFrame KeyTime="0:0:0.3" Value="#FFAB4721"/> 
      <EasingColorKeyFrame KeyTime="0:0:0.7" Value="#FF21AB49"/> 
     </ColorAnimationUsingKeyFrames> 
    </Storyboard> 
</Window.Resources> 
<Window.Triggers> 
    <EventTrigger RoutedEvent="FrameworkElement.Loaded"> 
     <BeginStoryboard Storyboard="{StaticResource simple_animation}"/> 
    </EventTrigger> 
</Window.Triggers> 
<Grid Margin="0,12,0,0"> 
    <Rectangle x:Name="rectangle" Fill="#FF21AB49" Margin="136,93,92,157" Stroke="Black"/> 
</Grid> 

爲簡單的動畫上面的代碼。 首先,您已創建動畫板以設置動畫,然後只有您可以動畫製作您想要動畫的動畫。 請嘗試上面的代碼,它會幫助你。

+0

感謝您的回答......但我終於意識到並非所有的wpf功能都可以在winform中調用.. :) – sheldon90