wpf Storyboard 不存在可解析名称“ ”的适用名称领域
Posted lonelyxmas
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了wpf Storyboard 不存在可解析名称“ ”的适用名称领域相关的知识,希望对你有一定的参考价值。
原文:wpf Storyboard 不存在可解析名称“ ”的适用名称领域
? ? ?写了一个 Storyboard ,如下:
? ? ? ? ? ? ? ?
DoubleAnimation crossLeftAnimation = new DoubleAnimation();
crossLeftAnimation.Duration = TimeSpan.FromSeconds(0.5);
Storyboard.SetTargetName(crossLeftAnimation, "imgCrossCartoon");
Storyboard.SetTargetProperty(crossLeftAnimation,
new PropertyPath(Canvas.LeftProperty));
DoubleAnimation crossTopAnimation = new DoubleAnimation();
crossTopAnimation.Duration = TimeSpan.FromSeconds(0.5);
Storyboard.SetTargetName(crossTopAnimation, "imgCrossCartoon");
Storyboard.SetTargetProperty(crossTopAnimation,
new PropertyPath(Canvas.TopProperty));
Storyboard myStoryboard=new Storyboard();
myStoryboard.Completed+=new EventHandler(myStoryboard_Completed);
this.imgCrossCartoon.IsEnabled= true;
if (id > 0)
{
crossLeftAnimation.From = Canvas.GetLeft(_calibrateCircles[id-1]);
crossLeftAnimation.To = Canvas.GetLeft(_calibrateCircles[id]);
crossTopAnimation.From = Canvas.GetTop(_calibrateCircles[id - 1]);
crossTopAnimation.To = Canvas.GetTop(_calibrateCircles[id]);
}
else
{
crossLeftAnimation.From = -40;
crossLeftAnimation.To = Canvas.GetLeft(_calibrateCircles[id]);
crossTopAnimation.From = -40;
crossTopAnimation.To = Canvas.GetTop(_calibrateCircles[id]);
}
myStoryboard.Children.Add(crossLeftAnimation);
myStoryboard.Children.Add(crossTopAnimation);
myStoryboard.Begin();
结果出现:Storyboard 不存在可解析名称“ ”的适用名称领域错误。后来参考http://social.msdn.microsoft.com/Forums/zh-TW/802/thread/1365449e-965d-4df7-82df-e3e0e8d0ca19,把最后一句改为:
? ? ? ? ? ? ? ? ? ? ? ? myStoryboard.Begin(this.imgCrossCartoon);
就好了。
以上是关于wpf Storyboard 不存在可解析名称“ ”的适用名称领域的主要内容,如果未能解决你的问题,请参考以下文章
为啥访问我的 Storyboard x:Name 在 Silverlight 中有效,但在 WPF 中无效?
名称空间“clr-namespace:CefSharp.Wpf;assembly=CefSharp.Wpf”中不存在名称 ChromiumWebBrowser
WPF 命名空间“System.ComponentModel.Composition”中不存在类型或命名空间名称“CompositionInitializer”