正确。我需要在Canvas下的C#中使用WPF Usercontrol动画的任何愚蠢样本。 我试过故事下的所有组合。开始(??????); 但它始终给出错误。任何线索的人?
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]);
我猜这是同一个故事。开始(这个); 但没有成功......
答案 0 :(得分:0)
Dmitry Boyko:
我找到了解决方案的人!
需要替换
Storyboard.SetTargetName(dbWidth, PluginUControl.Name);
与
Storyboard.SetTarget(dbWidth, PluginUControl);