如何在动画WPF Margin属性 [英] How to animate Margin property in WPF

查看:2529
本文介绍了如何在动画WPF Margin属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想搬到一个动画矩形对象,将其移动在x轴。我是新来WPF动画,开始了以下内容:

I want to move animate an rectangle object to move it in x-axis. I am new to WPF animation, started out with the following:

<Storyboard x:Key="MoveMe">
    <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" 
                                   Storyboard.TargetName="GroupTileSecond"
                                   Storyboard.TargetProperty="(**Margin.Left**)">

        <SplineDoubleKeyFrame KeyTime="00:00:00" Value="**134, 70,0,0**" />
        <SplineDoubleKeyFrame KeyTime="00:00:03" Value="**50, 70,0,0**" />
    </DoubleAnimationUsingKeyFrames>
</Storyboard>

显然发现我不能使用 Margin.Left Storyboard.TargetProperty 或使用的 134,70,0,0 的在Value属性。

Obviously found out that I cant use Margin.Left as Storyboard.TargetProperty or use 134,70,0,0 in Value property.

那么,如何在WPF XAML移动对象。

So, how do I move an object in XAML WPF.

推荐答案

保证金属性可以使用动画 ThicknessAnimation

<Storyboard >
     <ThicknessAnimationUsingKeyFrames Storyboard.TargetProperty="Margin" BeginTime="00:00:00">
        <SplineThicknessKeyFrame KeyTime="00:00:00" Value="134, 70,0,0" />
        <SplineThicknessKeyFrame KeyTime="00:00:03" Value="50, 70,0,0" />
     </ThicknessAnimationUsingKeyFrames>
</Storyboard>

这篇关于如何在动画WPF Margin属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆