带边距的DoubleAnimation

时间:2016-04-10 18:41:21

标签: c# wpf

我如何为用户控件的边距设置动画?我想直接在Window后台代码中执行此操作。这就是我所拥有的:

addServer = new AddServer();
addServer.Height = 300;
addServer.Width = 570;

// 252, 248, 26, 0
addServer.Margin = new Thickness(252, 550, 26, 0);
Main.Children.Add(addServer);

DoubleAnimation doubleAnimation = new DoubleAnimation();
doubleAnimation.From = 550;
doubleAnimation.To = 248;
doubleAnimation.Duration = new Duration(TimeSpan.FromSeconds(5));

Storyboard storyboard = new Storyboard();
storyboard.Children.Add(doubleAnimation);
Storyboard.SetTargetName(doubleAnimation, addServer.Name);
Storyboard.SetTargetProperty(doubleAnimation, new PropertyPath(addServer.Margin));

AddServer是我想要动画的UserControl。我希望实现的是动画中的飞行。

0 个答案:

没有答案