gpt4 book ai didi

windows-phone-7 - 自定义 Storyboard中的 "Cannot resolve TargetName"错误

转载 作者:行者123 更新时间:2023-12-05 01:33:59 25 4
gpt4 key购买 nike

在 WP7 silverlight 应用程序中,我想在特定事件上使用 Storyboard动画。
动画将按钮高度属性从 x 点更改为 y 点(更改为查询)。

我在我的程序中使用以下代码

   Storyboard myStoryBoard = new Storyboard();
myStoryBoard.Duration = new Duration(TimeSpan.FromMilliseconds(200));

DoubleAnimation myDoubleAnimation = new DoubleAnimation();
Storyboard.SetTargetName(myDoubleAnimation, button1.Name); // button1 is normal button on UI
Storyboard.SetTargetProperty(myDoubleAnimation, new PropertyPath(Button.HeightProperty));

myDoubleAnimation.From = 200;
myDoubleAnimation.To = 300;

myStoryBoard.Children.Add(myDoubleAnimation);
myStoryBoard.Begin();

当我运行我的代码时,我正在打
无法解析 TargetName button1 错误

我的问题有什么简单的解决方法吗?

最佳答案

我认为只有当 Storyboard 位于可视化树中时,您才能使用 SetTargetName。我建议改用 SetTarget:http://msdn.microsoft.com/en-us/library/system.windows.media.animation.storyboard.settarget%28v=vs.95%29.aspx

Storyboard.SetTarget(myDoubleAnimation, button1);

关于windows-phone-7 - 自定义 Storyboard中的 "Cannot resolve TargetName"错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8881578/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com