2012-10-22 2 views
1

사용자가 내 응용 프로그램에서 페이지를 이동하면 간단한 애니메이션이 이동하기 전에 항목이 사라지게되지만 작동하지 않고 이동 중이므로 즉시 이동합니다.뒤로 키를 누르면 애니메이션이 대기하지 않습니다.

코드 : 이제

 public PageClass() 
     { 
      BackKeyPress += OnBackKeyPressed; 
     } 

     void OnBackKeyPressed(object sender, CancelEventArgs e) 
     { 
      foreach (var control in ContentPanel.Children) 
       MainPage.FadeOutObject(control); 

      var translation = new TranslateTransform(); 

      PageTitle.RenderTransform = translation; 

      var s = new Storyboard(); 
      Storyboard.SetTarget(s, translation); 
      Storyboard.SetTargetProperty(s, new PropertyPath(TranslateTransform.YProperty)); 

      s.Children.Add(
        new DoubleAnimation() 
        { 
         From = -300, 
         To = 0, 
         Duration = new Duration(TimeSpan.FromSeconds(2.0)), 
         EasingFunction = new PowerEase { EasingMode = EasingMode.EaseInOut } 
        }); 

      s.Begin(); 

      s.Completed += (object sd, EventArgs ea) => 
      { 
       NavigationService.Navigate(new Uri("/MainPage.xaml", UriKind.Relative)); 
      }; 
     } 

이 그것이 바로 다시 MainPage에 간다, 작동하지 않는이 사람이 실마리가 무엇입니까?

답변

3

이전 페이지가 자동으로 처리되지 않도록하려면 e.Cancel을 추가하십시오. 이미 이동해야하는 페이지를 말하고 있기 때문에.

void OnBackKeyPressed(object sender, CancelEventArgs e) 
{ 
    e.Cancel = true; 

    foreach (var control in ContentPanel.Children) 
      MainPage.FadeOutObject(control); 

    //...rest of your code 
} 
관련 문제