1
나는 실버 라이트 어플리케이션을 만들었습니다. 이미지를 뒤집어서 코드 뒤에 스토리 보드를 만들었습니다. 그러나 오류 "대상 이름을 확인할 수 없습니다."이 표시됩니다.코드 뒤에서 실버 라이트로 이미지 바꾸기
Storyboard sbFlip = new Storyboard();
sbFlip.Duration = new Duration(TimeSpan.FromSeconds(3));
DoubleAnimationUsingKeyFrames FlipFront = new DoubleAnimationUsingKeyFrames();
DoubleAnimationUsingKeyFrames FlipBack = new DoubleAnimationUsingKeyFrames();
Storyboard.SetTargetName(FlipFront, strFrontSelectedValue);
Storyboard.SetTargetName(FlipBack, strBackSelectedValue);
Storyboard.SetTargetProperty(FlipFront, new PropertyPath("(UIElement.RenderTransform).(ScaleTransform.ScaleX)"));
Storyboard.SetTargetProperty(FlipBack, new PropertyPath("(UIElement.RenderTransform).(ScaleTransform.ScaleX)"));
SplineDoubleKeyFrame sFlipFront = new SplineDoubleKeyFrame();
SplineDoubleKeyFrame sFlipBack = new SplineDoubleKeyFrame();
sFlipFront.KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(500));
sFlipFront.Value = 0;
sFlipBack.KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(500));
sFlipBack.Value = 1;
FlipFront.KeyFrames.Add(sFlipFront);
FlipBack.KeyFrames.Add(sFlipBack);
sbFlip.Children.Add(FlipFront);
sbFlip.Children.Add(FlipBack);
sbFlip.AutoReverse = true;
sbFlip.Completed += new EventHandler(this.sbFlip_Completed);
sbFlip.Begin();
나는 어디가 잘못 될까요 ???
1st. 어느 선에서 오류가 발생합니까? 2 위. XAML로 만듭니다. 코드 숨김에 쓰레기 만들기를 그만 두십시오! – MyKuLLSKI
1. 마지막 줄에서이 오류가 발생했습니다. 2. 내가 스토리 보드를 n 개 필요로하기 때문에 xaml에서 그럴 수 없다. 그게 내가 codebehind로 옮겼습니다. –
XAML에 n 개의 숫자를 사용할 수 있습니다. 코드에서 수행 할 수있는 작업은 모두 XAML에서 수행 할 수 있습니다. 스토리 보드가 UI 컨트롤 (Window, UserControl)에 있는지 확인하고'this'를 전달하십시오 ...'sbFlip.Begin (this);' – MyKuLLSKI