Surface2014. 4. 10. 11:32

일단 스토리보드는 타겟이 있어야 한다 대부분 디자이너나 블랜드에서 만들면 타겟을

 

Storyboard.TargetName="xDetailItem"

 

이런코드가 삽입된다

 

일단 xaml에서 TargetName을 다 제거한다.. 그리고 이 타겟을 Behind에서 추가해준다.

 

일단 아래와 같이 제거

 

 <Storyboard x:Key="CalculatorOpen">
            <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)">
                <EasingDoubleKeyFrame KeyTime="0" Value="0" />
                <EasingDoubleKeyFrame KeyTime="0:0:0.3" Value="1" />
            </DoubleAnimationUsingKeyFrames>
            <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)">
                <EasingDoubleKeyFrame KeyTime="0" Value="0" />
                <EasingDoubleKeyFrame KeyTime="0:0:0.3" Value="1" />
            </DoubleAnimationUsingKeyFrames>
            <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)">
                <EasingDoubleKeyFrame KeyTime="0" Value="0" />
                <EasingDoubleKeyFrame KeyTime="0:0:0.3" Value="1" />
            </DoubleAnimationUsingKeyFrames>
        </Storyboard>

 

 

자 이제 code behind에서

 

  ScatterViewItem svi = new ScatterViewItem()
                {
                    Center = (e.Source as DragAndDropScatterViewItem).Center,
                    Content = CalUc,
                    Orientation = 0,
                    Width = 263,
                    Height = 311,
                    RenderTransformOrigin = new Point(0.5, 0.5),
                    CanScale = false,
                };
                TransformGroup transGroup = new TransformGroup();
                transGroup.Children.Add(new ScaleTransform());
                transGroup.Children.Add(new TranslateTransform());
                transGroup.Children.Add(new RotateTransform());
                transGroup.Children.Add(new SkewTransform());
                svi.RenderTransform = transGroup;
                xScatterView.Items.Add(svi);

 

이런식으로 오브젝트를  하나 만들었다.

xaml에 Transform을 이용하기 떄문에 오브젝트에서도 이렇게 만들어줘야 된다.

 

자 간단하게 타겟을 지정해보자.

 

   Storyboard sb = this.Resources["CalculatorOpen"] as Storyboard;

   sb.Begin(svi);

 

아... 간단하다. begin(오브젝트)만 붙이면 된다.

Posted by 동동(이재동)
Windows Phone 72011. 3. 11. 14:49

Behind에서 특정 큰트롤을 조정(예를 들면 visible)하거나 여러개의 콘트롤을 조정하여 특정 화면을 만들고 싶을때

 

스토리보드처럼 역동적이지 않고 화면을 바꾸고 싶을때 behind에서 일일히 조정하는것보다 VisualStateManager를 쓰

 

면 편하다.

 

image

 

일단 블랜드에 가서 State의 이름을 정한다. 나는 CollectionCoinState로 정했다.

 

다음에 Add State버튼을 눌러서 Add를 한다. 나는 CompleteCollect로 정했다.

 

다음 만든 CompleteCollect를 클릭하면 StoryBoard만들때처럼 Recoding On이라는 메세지와 함께 빨간줄이 쳐진다.

 

이때 자기가 만들고자 하는 상태를 만든다. 컨트롤을 숨긴다던지 아니면 보이게 한다던지

 

다 만들었으면

 

이제 이것을 실행해 보자.

 

Behind에서

 

VisualStateManager.GoToState(this, "CompleteCollect", true);                

 

이렇게 하면 아까 설정했던 상태를 그대로 적용해준다.

 

만약 State를 여러개 만들고 저기 가운데 이름만 바꾸면 여러개를 돌아가면서 바꿀수 있다.

Posted by 동동(이재동)
Windows Phone 72011. 2. 23. 15:05

스토리보드가 실행중인지 보는 메서드는

 

 

GetCurrentState()
로 알수 있다.
 
스토리보드를 Skip 하여 끝에 효과만 보게 할려면
 
SkipToFill();
 
을 쓴다.
 
예제
 
//스토리 보드가 실행중에 페이지가 넘어갈때 StoryBoard를 Skip 한다.
            if (DisappearDescriptionGuide.GetCurrentState() == System.Windows.Media.Animation.ClockState.Active)
            {
                DisappearDescriptionGuide.SkipToFill();
            }

 
Posted by 동동(이재동)