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 72012. 1. 26. 11:34

앱을 만들다보면 페이지간의 이동이 필요한 경우가 무척이나 많다.

그럼 어떻게 해서 데이터 전송을 할까?

여러가지 방법이 있는데 헷갈려 하는 사람들이 많아서 정리해보자.

1. Global Variable을 이용하는 방법

이건 쉽고 편리하긴하다.

App.xaml에

public string SecondPageText { get; set; }

이런식으로 정의 하고

(App.Current as App).SecondPageText = txtBox.Text;

이렇게 값을 넣을수 있다.

이렇게 하거나 아니면 Static Class를 만들어서 관리하는 방법도 있다.

 

2. Query String을 이용하는 방법

이건 예전에도 포스팅했고 가장 일반적인 방법임으로 패스

그냥 Navigate할때 쿼리처럼 쓰면 된다. web같이

 

3. PhoneApplicationSerivce States를 이용하는 방법

PhoneApplicationService.Current.State["Text"] = txtBox.Text;

txtBlock.Text = (string)PhoneApplicationService.Current.State["Text"];

머 이렇게 하는법이다. 주로 tombstone할때 사용하던 방식이다.

4. NextPage intance를 이용하는 방법

OnNavigateFrom할때 미리 가는 페이지의 instace를 받아서 보내는방법

viewModel에 직접 전달해줄수도 있어서 유용할수도 있다.

아마 사람들이 잘 모르는 방법일 것이다.

protected override void OnNavigatedFrom(System.Windows.Navigation.NavigationEventArgs e)
{
     base.OnNavigatedTo(e);
     if (e.Content is PageOne)
     {
         (e.Content as PageOne).txtBlock.Text = txtBox.Text;
     }
}

 

윈폰7을 공부하는 사람들이 가장 궁금해 할 수 있는 부분일꺼 같아서 공유해 본다.

Posted by 동동(이재동)