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#
 


How to create Secondary tiles on Windows phone start screen using c#

This is the third blog post of this series in which I am going to explain you how to create a secondary tile on Windows phone start screen.

 

Before going ahead I would like to give you a short summary on Secondary tiles.

 

What are Secondary tiles?

A secondary Tile is created programmatically by an application based on interaction from the user. Typical uses for a secondary Tile include scenarios where you want to show important information to the user on the Start screen of the phone.

 

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

 


 

2. Then create a new image folder having the name Images in your project and add some sample images to it.

 


 

3. We shall be using Create(Uri, ShellTileData) method to create a Tiles on Start Screen. Whenever this method will be called the UI will navigate to Start Screen.

 

The different parameters in the above method are

1. Uri – It is the Uri of any page within the application where the application will navigate to whenever user taps on this tile from start screen. It should be unique for each secondary tile. By unique uri we mean that more than one tile can navigate to the same page but each should have different tag in the uri which will be explained in the further post.

2. ShellTileData– This data class is used to provide different properties to the tiles created through this method. It can be of different types.

 

Note: One property of the Secondary tiles which are created through the above method is that each should have a unique uri.

 

So if we try to create more than one secondary tile having the same uri. It will give an exception and will lead to crash. So as to avoid the following situation we use the following method checktile given below to check whether any tile with same uri exist before or not on start screen.

 

 

As there are three different tile templates in Windows phone 8/8.1. We will be discussing an example of each of the types.

 
http://www.windowsapptutorials.com/windows-phone/different-tile-templates-properties-windows-phone
 


 

Flip tile

For creating a flip tile on start screen we shall be using FlipTileData class as discussed in our previous post.

Create a button on the MainPage to pin the tile. The code for click event handler of the button is given below.

 

 

Output Images:

 

Front


Back


 

Cyclic tile

For creating a cyclic tile on start screen we shall be using CyclicTileData class as discussed in our previous post.

Create a button on the MainPage to pin the tile. The code for click event handler of the button is given below.

 

 

Output Images:

 

Medium


Wide


 

Iconic tile

For creating an iconic tile on start screen we shall be using IconicTileData class as discussed in our previous post.

Create a button on the MainPage to pin the tile. The code for click event handler of the button is given below.

 

 

Output Images:

 

Medium


Wide


 

As a developer I would like you to experiment with the different tile templates to get a better understanding of tiles.

 

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

 
Download full project source Secondarytiles.zip
 

In the next blog post of this series I will explain you how to update and delete secondary tiles pinned on start screen.

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