我目前正致力于将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
答案 0 :(得分: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>
上面的简单动画代码。 首先,您要创建故事板以进行动画处理,然后只有您可以为要设置动画的动画设置动画。 请尝试以上代码,它会对您有所帮助。