0

我目前正在研究结合 emgu cv(作为图像处理)和 wpf(2D/3D 重建)的项目。

该项目首先是在 Windows 窗体中构建的,直到我发现如果我想构建 2D/3D 对象,我必须使用 WPF 控件(例如视口 3D),它将覆盖在图像帧/捕获的顶部......

因此,我使用 usercontrol 以 Windows 形式托管 WPF 控件,并且代码成功运行... http://i.imgur.com/F9O7i.png

但是,当我尝试制作一个简单的动画(例如矩形背景颜色变成另一种颜色等)时,它不起作用..

知道如何解决这个问题吗? http://i.imgur.com/2ZCph.png

4

1 回答 1

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>

上面的简单动画代码。首先,您必须创建 Storyboard 来制作动画,然后只有您可以制作想要制作动画的动画。请尝试上面的代码,它将对您有所帮助。

于 2012-06-10T13:01:31.723 回答