码迷,mamicode.com
首页 > Windows程序 > 详细

wpf Storyboard 不存在可解析名称“ ”的适用名称领域

时间:2018-09-21 10:58:45      阅读:262      评论:0      收藏:0      [点我收藏+]

标签:mile   https   opp   code   temp   time   sof   oss   phoenix   

原文: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 不存在可解析名称“ ”的适用名称领域

标签:mile   https   opp   code   temp   time   sof   oss   phoenix   

原文地址:https://www.cnblogs.com/lonelyxmas/p/9684897.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!