【发布时间】:2011-11-18 11:34:08
【问题描述】:
正确。我需要 Canvas 下 C# 中的任何愚蠢的 WPF Usercontrol 动画示例。 我尝试了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]);
我猜是同一个故事。Begin(this); 但没有成功...
【问题讨论】:
-
谢谢!但我需要通过 C# 中的代码 100% 完成