2012-05-19 4 views
0

는이 코드를 가지고,하지만 난이 있기 때문에 내가 sb.Begin()를 호출 할 때 예외를 throw합니다 사용할 수 없습니다Silverlight "애니메이션 대상이 지정되지 않았습니다."

애니메이션 대상을 지정하지합니다.

내가 틀렸다
public void TableCardAnimation(UserControl cardControl, double Height, double Width) 
    { 
     Storyboard sb = new Storyboard(); 
     DoubleAnimation animHeight = new DoubleAnimation(); 
     animHeight.Duration = new Duration(new TimeSpan(0, 0, 2)); 
     animHeight.From = cardControl.Height; 
     animHeight.To = Height; 
     sb.Children.Add(animHeight); 
     Storyboard.SetTarget(animHeight, cardControl); 
     Storyboard.SetTargetProperty(animHeight, new PropertyPath("(Height)")); 


     DoubleAnimation animWidth = new DoubleAnimation(); 
     animWidth.Duration = new Duration(new TimeSpan(0, 0, 2)); 
     animWidth.From = cardControl.Width; 
     animWidth.To = Width; 
     sb.Children.Add(animWidth); 
     Storyboard.SetTarget(animWidth, cardControl); 
     Storyboard.SetTargetProperty(animHeight, new PropertyPath("(Width)")); 

     sb.Begin(); 
    } 

? . :(

답변

0

은 분명히 그것은 라인에

만 입력 오류 : 당신은 animHeight 차에 대한 대상 속성을 설정 한

Storyboard.SetTargetProperty(animHeight, new PropertyPath("(Width)")); 

하지만 animWidth 대상 속성이 아직 설정되지 당신은 수 있습니다.

Storyboard.SetTargetProperty(animWidth, new PropertyPath("(Width)")); 

을 그리고 당신이 사용하는 이유 "(Width)" 대신 "Width"

: 싶지?
관련 문제