2013-10-20 4 views
4

내 Windows Phone 8 응용 프로그램에 오리엔테이션 변경 애니메이션을 추가하는 가장 쉬운 방법은 무엇입니까? 나는 메시지, 캘린더 등의 네이티브 앱처럼 보이는 것에 관심이 있습니다. 빠르고 간단한 솔루션을 찾고 있었고 작업이 NuGet의 DynamicOrientionChanges 라이브러리 였지만 Windows에서는 프레임 속도가 큰 문제가 있습니다. 전화 8.WP8 오리엔테이션 변경 애니메이션

답변

5

당신은 Windows.Phone.Toolkit를 사용하고 여기에 전시 한, OrientationChangedEvent을 처리 할 수 ​​

http://mobileworld.appamundi.com/blogs/andywigley/archive/2010/11/23/windows-phone-7-page-orientation-change-animations.aspx

난 그냥, 여기 링크 된 문서의 소스 코드 일부를 복사 할 수 있습니다 페이지가 오프라인이되는 경우. 여기에는 애니메이션이 변경 사항과 일치하도록하기 위해 현재 방향이 어느 오리엔테이션에서 왔는지 추적하는 추가 논리가 포함되어 있습니다.

public partial class MainPage : PhoneApplicationPage 
{ 
    PageOrientation lastOrientation; 

    // Constructor 
    public MainPage() 
    { 
     InitializeComponent(); 

     this.OrientationChanged += new EventHandler<OrientationChangedEventArgs>(MainPage_OrientationChanged); 

     lastOrientation = this.Orientation; 
    } 

    void MainPage_OrientationChanged(object sender, OrientationChangedEventArgs e) 
    { 
     PageOrientation newOrientation = e.Orientation; 
     Debug.WriteLine("New orientation: " + newOrientation.ToString()); 

     // Orientations are (clockwise) 'PortraitUp', 'LandscapeRight', 'LandscapeLeft' 

     RotateTransition transitionElement = new RotateTransition(); 

     switch (newOrientation) 
     { 
      case PageOrientation.Landscape: 
      case PageOrientation.LandscapeRight: 
       // Come here from PortraitUp (i.e. clockwise) or LandscapeLeft? 
       if (lastOrientation == PageOrientation.PortraitUp) 
        transitionElement.Mode = RotateTransitionMode.In90Counterclockwise; 
       else 
        transitionElement.Mode = RotateTransitionMode.In180Clockwise; 
       break; 
      case PageOrientation.LandscapeLeft: 
       // Come here from LandscapeRight or PortraitUp? 
       if (lastOrientation == PageOrientation.LandscapeRight) 
        transitionElement.Mode = RotateTransitionMode.In180Counterclockwise; 
       else 
        transitionElement.Mode = RotateTransitionMode.In90Clockwise; 
       break; 
      case PageOrientation.Portrait: 
      case PageOrientation.PortraitUp: 
       // Come here from LandscapeLeft or LandscapeRight? 
       if (lastOrientation == PageOrientation.LandscapeLeft) 
        transitionElement.Mode = RotateTransitionMode.In90Counterclockwise; 
       else 
        transitionElement.Mode = RotateTransitionMode.In90Clockwise; 
       break; 
      default: 
       break; 
     } 

     // Execute the transition 
     PhoneApplicationPage phoneApplicationPage = (PhoneApplicationPage)(((PhoneApplicationFrame)Application.Current.RootVisual)).Content; 
     ITransition transition = transitionElement.GetTransition(phoneApplicationPage); 
     transition.Completed += delegate 
     { 
      transition.Stop(); 
     }; 
     transition.Begin(); 

     lastOrientation = newOrientation; 
    } 
}