I use live title to launch a specific page:
Live tile in Home screen –launch–> P1 after a task and goto –> P2 –> MainPage
When you click back button in MainPage the app won’t exit instead it goes to P2 in a loop fashion.
Here is the code:
try
{
ShellTile TileToFind = ShellTile.ActiveTiles.FirstOrDefault(x => x.NavigationUri.ToString().Contains("PageTakePic.xaml"));
if (TileToFind == null)
{
StandardTileData NewTileData = new StandardTileData
{
//BackgroundImage = new Uri("Red.jpg", UriKind.Relative),
//--front tile
Title = "Take Pic",
//Count = 12,
BackTitle = "Quick Access",
//--40 char
BackContent = "Take Pic",
//BackBackgroundImage = new Uri("Blue.jpg", UriKind.Relative)
};
// Create the Tile and pin it to Start. This will cause a navigation to Start and a deactivation of our application.
ShellTile.Create(new Uri("/PageTakePic.xaml", UriKind.Relative), NewTileData);
}
else
{
MessageBox.Show("A live title created for this service already.");
}
}
catch (Exception ex)
{
MessageBox.Show("Try again. Error encountered: " + ex.Message);
NavigationService.Navigate(new Uri("/MainPage.xaml", UriKind.Relative));
}
Update:
Live tile in Home screen –launch–> P1 (PageTakePic.xaml) –> P2 –> MainPage
using below method not working In MainPage. It still goes into a loop:
protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
{
base.OnNavigatedTo(e);
NavigationService.RemoveBackEntry();
}
It’s a common issue to consider with Deep Links from Live Tiles in Mango. What you need to do is remove the BackStack entries when you hit your Main Page so that hitting the back button will exit the app.
Here is a snippet that may help: