繁体   English   中英

C#中的用户控件动画

[英]Usercontrol animation in C#

正确。 我需要Canvas下C#中WPF用户控件动画的任何愚蠢示例。 我尝试了story.Begin(??????);下的所有组合; 但是它总是会出错。 有线索吗?

Storyboard story = new Storyboard();

DoubleAnimation dbWidth = new DoubleAnimation();
dbWidth.From = 0;
dbWidth.To = 200;
dbWidth.Duration = new Duration(TimeSpan.FromSeconds(.25));

DoubleAnimation dbHeight = new DoubleAnimation();
dbHeight.From = 0;
dbHeight.To = 200;
dbHeight.Duration = dbWidth.Duration;

story.Children.Add(dbWidth);
Storyboard.SetTargetName(dbWidth, PluginUControl.Name);
Storyboard.SetTargetProperty(dbWidth, new PropertyPath(UserControl.WidthProperty));

story.Children.Add(dbHeight);
Storyboard.SetTargetName(dbHeight, PluginUControl.Name);
Storyboard.SetTargetProperty(dbHeight, new PropertyPath(UserControl.HeightProperty));

story.Begin(??????);

更新:

我也尝试这样做

 story.Begin((MainWindow)App.Current.Windows[0]);

我猜这是同一回事。 但没有成功...

德米特里·博伊科(Dmitry Boyko):

我找到了解决方案的家伙!

需要更换

Storyboard.SetTargetName(dbWidth, PluginUControl.Name);

Storyboard.SetTarget(dbWidth, PluginUControl);

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM