原文:
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);
就好了。