views:

566

answers:

3

I believe this is just a problem for me, due to my lack of programming ability. I am currently exploring transitions between page navigation with Windows Phone apps. I was originally using storyboards, and completed event handlers to have my pages animate on and off screen. These leads to the a problem when you want to navigate to many pages from one page, using the same transition.

So I have started looking at OnNavigatedTo, and OnNavigatingFrom events and while it is working nicely for OnNavigatedTo, the later just wont work. It seems the Microsoft.Phone.Navigation assembly does not contain OnNavigatingFrom, and referencing System.Windows.Navigation, compiles ok, but I cant get pages to animate off upon navigation.

I have a button on my Page2, which I want to go back to my MainPage (after I over-rided the back key with a message box for testing). I have transitions made on the page, and I have this as the event handler code...

private void btnP2_BackToP1Clicked(object sender, System.Windows.RoutedEventArgs e)
 {          
    NavigationService.Navigate(new Uri("/MainPage.xaml", UriKind.Relative));        
}

With this code for the OnNavigatedTo and OnNavigatingFrom events...

protected override void OnNavigatedTo(PhoneNavigationEventArgs e)
{
    PageTransition_In.Begin();
}

// //

protected override void OnNavigatingFrom(NavigatingCancelEventArgs e)
{
    PageTransition_Out.Begin();

    base.OnNavigatingFrom(e);
}

I have the feeling that OnNavigatingFrom may not(yet) be supported for Windows Phone Apps. OnNavigatedFrom is part of Microsoft.Phone.Navigation, but it only performs actions once the page is no longer active, which is too late to perform any animation effects.

A: 

I believe that you need to add an event that captures the transition completion. Check out the demo that Microsoft provides for a list view application.

Mitchell Skurnik
unfortunately that is not the issue. The transition doesn't play at all, the page just changes, however, when I navigate to the page, I get to see the animation.The OnNavigatingFrom event is supposed to fire before the page becomes inactive, and the OnNavigatedTo event fires once the page is active within the ApplicationFrame.The fact that OnNavigatingFrom is inherited from the Silverlight Page assembly, and is not present in Microsoft.Phone, may show it is not supported. Even though the event is listed on the page showing Microsoft.Phone.Navigation events on msdn.http://bit.ly/brBzXD
Martin Anderson
Yeah it looks like there are a few bugs in the SDK. I am having some problems with SOAP SSL authentication.
Mitchell Skurnik
A: 

The approach you are taking is not quite correct. Instead it is better to alter the page frame to know how to do transitions between pages. You can see a good examples of this on a Channel 9 vid or on Avi Pilosof's blog.

Example:

<ControlTemplate x:Key="TransitioningFrame" TargetType="navigation:PhoneApplicationFrame">
  <Border>
    <toolkit:TransitioningContentControl
        Content="{TemplateBinding Content}" Transition="DownTransition" />
  </Border>
</ControlTemplate>
Technium
A: 

I am baffled why we need to roll our own smooth transitions for WinPhone7, but there it is. Jeff Brand (SlickThought.net) seems to have the best solution so far. Here is a nice article with a walkthrough video and sample code, though his sample code in the article was for the April CTP and appears to be broken in the Beta tools.

Scott Fletcher