【问题标题】:Usercontrol animation in C#C#中的用户控件动画
【发布时间】: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# .net wpf animation


【解决方案1】:

德米特里·博伊科:

伙计们,我找到了解决方案!

需要更换

Storyboard.SetTargetName(dbWidth, PluginUControl.Name);

与

Storyboard.SetTarget(dbWidth, PluginUControl);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-05-20
    • 2016-05-12
    • 1970-01-01
    • 1970-01-01
    • 2023-04-05
    • 2013-07-18
    • 1970-01-01
    相关资源
    最近更新 更多