在C#用户控件动画 [英] Usercontrol animation in C#
本文介绍了在C#用户控件动画的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
正确的。我需要在C#下的帆布WPF用户控件动画的任何愚蠢的样本。
我尝试了所有组合story.Begin下(??????);
但它总是给人一个错误。任何线索家伙?
Correct. I need any stupid sample of WPF Usercontrol animation in C# under the Canvas. I tried all combinations under story.Begin(??????); But it gives an error always. Any clue guys?
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]);
我猜测,这是一样的story.Begin(本);
但没有成功...
I guessed that it is the same story.Begin(this); but no success...
推荐答案
梅德博伊科:
我找到了解决办法家伙!
I found the solution guys!
它需要替换
Storyboard.SetTargetName(dbWidth, PluginUControl.Name);
与
Storyboard.SetTarget(dbWidth, PluginUControl);
这篇关于在C#用户控件动画的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文