我已經在C#中創建了一個動畫板來動畫在畫布上進行縮放轉換。縮放轉換是一種佈局轉換。下面是我的動畫C#代碼:在WPF中動畫縮放佈局轉換的異常
Storyboard Configuring = new Storyboard();
if (NexusRoot != null)
{
var current = (NexusRoot.LayoutTransform as ScaleTransform).ScaleX;
Duration duration = new Duration(TimeSpan.FromSeconds(1));
DoubleAnimation myDoubleAnimation1 = new DoubleAnimation();
myDoubleAnimation1.Duration = duration;
Configuring.Children.Add(myDoubleAnimation1);
myDoubleAnimation1.From = current;
myDoubleAnimation1.To = scale;
Storyboard.SetTarget(myDoubleAnimation1, NexusRoot);
Storyboard.SetTargetProperty(myDoubleAnimation1, (PropertyPath)new PropertyPathConverter().ConvertFromString("(UIElement.LayoutTransform).(ScaleTransform.ScaleX)"));
DoubleAnimation myDoubleAnimation2 = new DoubleAnimation();
myDoubleAnimation2.Duration = duration;
Configuring.Children.Add(myDoubleAnimation2);
myDoubleAnimation2.From = current;
myDoubleAnimation2.To = scale;
Storyboard.SetTargetName(myDoubleAnimation2, "NexusRoot");
Storyboard.SetTargetProperty(myDoubleAnimation2, (PropertyPath)new PropertyPathConverter().ConvertFromString("(UIElement.LayoutTransform).(ScaleTransform.ScaleY)"));
}
當我運行這個動畫,它拋出以下異常。
System.ArgumentNullException是 抓消息= 「值不能爲空 \ r \ n參數名:DP」
源= 「WindowsBase」 PARAMNAME = 「DP」 堆棧跟蹤: 在System.Windows。 DependencyObject.GetValue(的DependencyProperty DP) 在System.Windows.Media.Animation.Storyboard.ProcessComplexPath(HybridDictionary的 clockMappings,DependencyObject的 targetObject,的PropertyPath路徑, AnimationClock應用AnimationClock應用, 的HandoffBehavior的HandoffBehavior,Int64的 層) 在System.Windows.Media.Animation.Storyboard.ClockTreeWalkRecursive(時鐘 currentClock,DependencyObject的 containingObject,INameScope 名稱範圍,DependencyObject的 parentObject,字符串parentObjectName, 的PropertyPath parentPropertyPath, 的HandoffBehavior的HandoffBehavior, HybridDictionary的clockMappings,Int64的 在System.Windows.Media.Animation.Storyboard.ClockTreeWalkRecursive(時鐘 currentClock,DependencyObject的層) containingObject,INameScope 名稱範圍,DependencyObject的 parentObject,字符串parentObjectName, 的PropertyPath parentPropertyPath, 的HandoffBehavior的HandoffBehavior, HybridDictionary的clockMappings,Int64的 層) 在System.Windows.Media.Animation.Storyboard.BeginCommon(DependencyObject的 containingObject,INameScope 名稱範圍,的HandoffBehavior 的HandoffBehavior,布爾 isControllable,Int64的層) 設置\ lbeaver \ Desktop \ StormFront \ WPF \ StormFront \ StormFront \ NexusDesigner.xaml在System.Windows.Media.Animation.Storyboard.Begin() at StormFront.NexusDesigner.ScaleCanvasAnimation(Double scale)in C:\ Documents and .cs:行 544 InnerException:
如何阻止發生這種異常?
能否請您更好的格式文本?堆棧跟蹤不可讀 – arconaut 2010-02-08 20:44:31
'NexusDesigner.xaml.cs:line 544' Line 554?現在殺了我。 – Will 2010-02-08 20:46:30
堆棧跟蹤沒有任何幫助。正如你可以看到異常的來源是WindowsBase,而不是我的代碼。 – Levi 2010-02-08 21:33:38