How to pin the application tile to the start screen from code
This article shows how to pin the application to the start screen from code (dynamically).
The application tile is the default tile created for an app when the user pins it to the start screen. While you can set it's default values, there is no way to manually create the "real" application tile in code.
While you can't create the application tile in code, you can create a secondary tile in code that looks and behaves exactly the same. The code to create a secondary tile is given in Working with Live Tiles on Windows Phone#Secondary Tile.
The special "trick" here is to check whether the application tile has already been defined before creating the "pseudo" application tile. Do this by testing whether the tile's navigation URI is the main page of the app (in this case MainPage.xaml). Then we create a secondary tile using the same field values and with navigation URI of the app start page.
private void PinToStart()
StandardTileData standardTileData = new StandardTileData();
standardTileData.BackgroundImage = null;
standardTileData.Title = "Pined From Application";
standardTileData.Count = 5;
standardTileData.BackTitle = "Back Title Data";
standardTileData.BackContent = "Back Content Data";
standardTileData.BackBackgroundImage = null;
// Check if the application tile has already been defined - this is a tile that links to the app main page
ShellTile tiletopin = ShellTile.ActiveTiles.FirstOrDefault(x => x.NavigationUri.ToString().Contains("MainPage.xaml"));
if (tiletopin == null)
//Create ShellTile linking to main page of app
ShellTile.Create(new Uri("/MainPage.xaml", UriKind.Relative), standardTileData);
MessageBox.Show("Application is already Pinned");