Daniel Little Coding Blog
Daniel Little Coding Blog

A blog about .net development and the web.

Daniel Little
Author

Daniel Little (lavinski) is a Brisbane based software developer.

Share


Our Newsletter


Like this blog? Get each new post as soon it's posted.

Tags


Twitter


Silverlight Page Transition Complete Event

Daniel LittleDaniel Little

While creating a mixed silverlight and xna WP7 application I started to add in page transitions with the silverlight toolkit. For the silverlight part of the application they work perfectly however when transitioning to the game screen the animation was not present.

This is because in OnNavigatedTo i'm obtaining the graphics device which overrides the rendering and this occurs before the animations starts.

At this point you have two choices, implements a transition like effect manually in xna or delay obtaining the graphics device until the animation completes and display some content to transition with.

I'm going to give a sample of how to do the latter.

public GamePage()
{
    tansitionEnd = new RoutedEventHandler(GamePage_EndTransition);
}

protected override void OnNavigatedTo(NavigationEventArgs e)
{
    TransitionService.GetNavigationInTransition(this).EndTransition += tansitionEnd;
    base.OnNavigatedTo(e);
}

protected void GamePage_EndTransition(object sender, RoutedEventArgs e)
{
    TransitionService.GetNavigationInTransition(this).EndTransition -= tansitionEnd;
}

The reason I picked the latter is because I will be using silverlight to render some parts of the UI. It's also important to note that as soon as you share the graphics device page level transitions will not render as xna takes over. However as stated above it's still possible to create a transition manually inside xna.

Daniel Little
Author

Daniel Little

Daniel Little (lavinski) is a Brisbane based software developer.

Comments