Adding a secondary tile that ‘deep links’ into your application is a trivial task and can be done in just a few lines of code…
private void button1_Click(object sender, RoutedEventArgs e)
{
ShellTile tile = ShellTile.ActiveTiles.FirstOrDefault(x => x.NavigationUri.ToString() == "/Page2.xaml");
if (tile == null)
{
StandardTileData secondaryTile = new StandardTileData
{
Title = "My app",
BackgroundImage = new Uri("/ApplicationIcon.png", UriKind.Relative),
Count = 13,
BackTitle = "News",
BackBackgroundImage = null,
BackContent = "Something happened on the way to heaven..."
};
ShellTile.Create(new Uri("/Page2.xaml", UriKind.Relative), secondaryTile);
}
}
The problem now is: How can I debug my application when launched from a secondary tile since debugger gets detached once you click it?
The smarter solution I’ve seen is to temporarily add a background task, this way debugger remains attached and you can continue debugging as usual, here are the steps:
- Add a new “Windows Phone Scheduled Task agent” project to your solution.
- Add a reference to it from your main application (see below)
That’s all: now you can launch your app, close it on emulator and see that it is still running and ready to trigger any breakpoint once you hit the secondary tile.
Hope it helps!