I am using a MediaElement to play music in my metro app. I want the Music keeps playing even if I navigate to another Page.
In the following Thread that question was
It's possible your Navigated handler where you try to get the visual tree child gets called before the visual tree is fully loaded (added to visual tree). You could try moving your code to the Loaded event handler.
EDIT*
I confirmed my theory by making the following change:
public sealed partial class MainPage : Page
{
public MainPage()
{
this.InitializeComponent();
this.Loaded += OnLoaded;
}
private void OnLoaded(object sender, RoutedEventArgs e)
{
DependencyObject rootGrid = VisualTreeHelper.GetChild(Window.Current.Content, 0);
MediaElement rootMediaElement = (MediaElement)VisualTreeHelper.GetChild(rootGrid, 0);
}
}