A couple of weeks ago I was working on a problem with handing audio over multiple pages in an application. It worked out well until the updated toolkit that came out in the beginning of November. I tried to add page transitions and after a day of frustration I found that my MediaElement injection broke the ability for page transitions.

The last solution was based on creating a ControlTemplate with a MediaElement in and ad that as the Template for the root frame, this breaks the ability for page transitions. As soon as I identified the problem I started to look for a solution. The solution was even simpler than I first anticipated. Instead of the injection I just added the MediaElemet as a resource in the App.xaml and then exposing it as a property. The code looks like this for the xaml part:


    

The code behind part is even simpler, it looks like this:

public static MediaElement GlobalMediaElement
{
  get { return Current.Resources["GlobalMedia"] as MediaElement; }
}

And you access it as before by calling it up in the page you need it on

var AppMediaElement = App.GlobalMediaElement;

There, simpler, cleaner and works as good as the first solution, and now I finally can start to use the page transitions again, sweet.

Update: As the MediaElement is very expensive it should be used with caution and here I will instantiate it at App level. In my case it is a player that Will play music and stream from the net so the purpose is to have it playing as long as I have music playing. However if you are not using it continuously you should not have a MediaElement like this. 

Update 2: I included a little testproject with code samples for this as well, that shows it works for both streams and included audio and should work for IsoStoraged files.

/ Håkan Reis