1. 程式人生 > >wpf Storyboard 不存在可解析名稱“ ”的適用名稱領域

wpf Storyboard 不存在可解析名稱“ ”的適用名稱領域

eas phoenix () set rate sof 領域 child this

原文: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 不存在可解析名稱“ ”的適用名稱領域