如何在UWP应用程序中设置椭圆的宽度和高度的动画

cro*_*oxy 3 c# animation xaml uwp

我正在尝试Ellipse在XAML 中为元素的width和height属性设置动画.我在网上找到了一些例子,但似乎都没有.
我敢肯定我只缺少一点点愚蠢的东西.这是我在xaml中的动画:

<Page.Resources>
    <Storyboard x:Name="PressFormLogin" Storyboard.TargetName="OuterEllipse">
        <DoubleAnimation Storyboard.TargetProperty="Width" From="259.0" To="149.0" Duration="0:0:5" />
        <DoubleAnimation Storyboard.TargetProperty="Height" From="259.0" To="149.0" Duration="0:0:5" />
    </Storyboard>
 </Page.Ressources>
Run Code Online (Sandbox Code Playgroud)

EllipseXAML中的元素:

<Ellipse x:Name="OuterEllipse"  Width="259" Height="259" Fill="#FF5AA1BA" />
Run Code Online (Sandbox Code Playgroud)

我如何尝试在后面的代码中启动动画:

PressFormLogin.Begin();
Run Code Online (Sandbox Code Playgroud)

这是我第一次在我的一个应用程序中使用动画,如果有人能给我推进正确的方向,那就太好了.

sib*_*bbl 6

尝试EnableDependentAnimation="True"为你的设置DoubleAnimation.请参阅MSDN上的EnableDependentAnimation.

  • 最好不要将DependentAnimation设置为true.相反,最好使用RenderTransform并为Scale.X和Scale.Y设置动画 (3认同)
  • @NghiaNghia来自上面链接的报价:"谨慎使用此属性,因为将其设置为true意味着您故意确认动画在运行时可能会减慢UI线程上的其他操作." (2认同)