2011-08-03 4 views
2

여기 내 UserControl을InvalidOperationException이 처리되지 않은이었다 - WPF 경로

<Grid x:Name="Grid"> 
    <Path Name="Path1" Data="M0.5,0.5 L179.5,0.5 L179.5,249.5 L0.5,249.5 z" Stretch="Fill" Stroke="Purple" StrokeThickness="1"> 
     <Path.Fill> 
      <SolidColorBrush Color="Blue" Opacity="0.4"/> 
     </Path.Fill> 
    </Path> 
    <Grid.Resources> 
     <Storyboard x:Key="Path_Ani"> 
      <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.X)" Storyboard.TargetName="Path1"> 
       <EasingDoubleKeyFrame KeyTime="0" Value="0"/> 
       <EasingDoubleKeyFrame KeyTime="0:0:0.2" Value="-58.515"/> 
      </DoubleAnimationUsingKeyFrames> 
      <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.Y)" Storyboard.TargetName="Path1"> 
       <EasingDoubleKeyFrame KeyTime="0" Value="0"/> 
       <EasingDoubleKeyFrame KeyTime="0:0:0.2" Value="-129.167"/> 
      </DoubleAnimationUsingKeyFrames> 
      <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)" Storyboard.TargetName="Path1"> 
       <EasingDoubleKeyFrame KeyTime="0" Value="1"/> 
       <EasingDoubleKeyFrame KeyTime="0:0:0.2" Value="0.544"/> 
      </DoubleAnimationUsingKeyFrames> 
      <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)" Storyboard.TargetName="Path1"> 
       <EasingDoubleKeyFrame KeyTime="0" Value="1"/> 
       <EasingDoubleKeyFrame KeyTime="0:0:0.2" Value="0.806"/> 
      </DoubleAnimationUsingKeyFrames> 
      <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[1].(SkewTransform.AngleX)" Storyboard.TargetName="Path1"> 
       <EasingDoubleKeyFrame KeyTime="0" Value="0"/> 
       <EasingDoubleKeyFrame KeyTime="0:0:0.2" Value="5.628"/> 
      </DoubleAnimationUsingKeyFrames> 
      <PointAnimationUsingKeyFrames Storyboard.TargetProperty="(Path.Data).(PathGeometry.Figures)[0].(PathFigure.Segments)[1].(LineSegment.Point)" Storyboard.TargetName="Path1"> 
       <EasingPointKeyFrame KeyTime="0" Value="100.5,140.5"/> 
       <EasingPointKeyFrame KeyTime="0:0:0.2" Value="104.175476605516,140.5"/> 
      </PointAnimationUsingKeyFrames> 
     </Storyboard> 
    </Grid.Resources> 
</Grid> 

입니다 그리고 난 그런 스토리 보드 전화 :

private void MyTest_MouseDown(object sender, MouseButtonEventArgs e) 
{ 
    Storyboard sbdCardAnim = (Storyboard)MyTest.Grid.Resources["Path_Ani"]; 
    sbdCardAnim.Begin(); 
} 

을 그리고 난 클릭하면 내가이 오류 :

'[Unknown]' property does not point to a DependencyObject in path '(0).(1)[3].(2)'. 

이 오류의 원인이되는 문제를 어떻게 해결합니까?

답변

1

당신의 애니메이션은 경로 집합이 RenderTransform으로 정의되었지만 경로의 실제 RenderTransform은 정의되지 않았으므로 null 인 것처럼 보입니다.

<!-- The RenderTransform which is expected looks something like this 
     (while no animation targets the third and therefore unknown transform 
     it only makes sense for it to be a RotateTransform) --> 
    <Path.RenderTransform> 
     <TransformGroup> 
      <ScaleTransform /> 
      <SkewTransform /> 
      <RotateTransform /> 
      <TranslateTransform /> 
     </TransformGroup> 
    </Path.RenderTransform> 

PointAnimation의 경로

는 예상대로으로 RenderTransform이 정의 된 경우 여전히 오류가있을 것 같은 경로에 실제 데이터에 적합하지 않는 것 같습니다.

관련 문제