How to update and delete Secondary tiles on Windows phone start screen using c#

This is the fourth blog post of this series in which I am going to explain you how to update or delete secondary tiles on Windows phone start screen.

We will be using the following reference of the last post to create secondary tiles on start screen.

http://www.windowsapptutorials.com/windows-phone/how-to-create-secondary-tiles-on-windows-phone-start-screen-using-c

 

1. First of all create a new project having the name Tiles.

 


 

2. Then add three buttons on the MainPage.xaml to Create, Update and Delete a secondary tile which is pinned on start screen.

 


 

3. Our initial step would be to create a tile on Windows phone Startscreen.

 

Creating a Secondary tile

The code for the click event handler of create button is given below. We will be using Iconic tile template to create a Secondary tile on start screen.

 

To uniquely identify the tile that is created on start screen. We will be using battery as id in the Navigation URI of tile.

 

 

Output images

 

Medium tile


 

Wide tile


 

Updating a Secondary tile

To update a secondary tile we must first check whether the tile with the given id exists on start screen. If the tile with current id exists on start screen we will be using Update(ShellTileData) method to update the tile.

 

Different steps we need to follow to update the tile are

1. First identify the tile with the given id on start screen.

2. Second step is to prepare the Shell tile data class with updated properties.

3. Then call the update tile method to update the tile.

 

The code for the click event handler of the update button is given below.

 

 

Output images (after calling update function)

 

Medium tile


 

Wide tile


 

This is the most common approach followed by most developers in the market to update the live tiles especially the tiles which show the battery life of your phone. In the coming post of this series I shall be explaining you to how to make live tiles for your Windows phone apps.

 

Deleting a Secondary tile

A secondary tile of Windows phone app that is pinned to start screen can be deleted by one of the following methods given below.

 

1. When the application is uninstalled from the phone all the secondary tiles of that application are automatically deleted from the start screen.

2. User can easily unpin the tile from start screen manually.

3. We can easily delete the tile from start screen dynamically using the Delete() Method.

 

Different steps that you need to follow to delete a secondary tile

1. Identify the tile with the given id on start screen.

2. Call the delete method to delete the tile from start screen.

 

The code for the click event handler of the delete button is given below.

 

 

Note: I have used the Iconic Template class in this following post to explain you the update and delete methods of the ShellTile Class. But you can follow the same approach for the different tile templates.

 

I hope this post will be helpful to you. If you have any doubts related to this article you can download the full project source file from the link given below.

 
Download full project source file Tiles.zip
 

In the coming post of this series I shall be explaining you how to create live tiles for your Windows phone application. Stay tuned or you can subscribe to our newsletter.

 
Introduction to tiles in Windows phone app
Different tile templates and their properties in Windows phone
How to create Secondary tiles on Windows phone start screen using c#
 


Chetan Gulati

Currently am doing B TECH in IT from Delhi Technological University. App development is my passion. Believe in quality rather than quantity.

Read more:
How to create your first Windows Phone app
How to change the App name and Tile name of your Windows phone app
Data binding in Windows Phone app – One way binding
Close