Windows Phone 7

Delete Secondary Tiles in Windows Phone 7.5 or Mango Phone

Before we will see the way to delete secondary tiles, I strongly suggest you to read these two articles

Live Tiles in Windows Phone 7.5 or Mango phone

Restore and Preserve Page State for Windows Phone 7.5 or Mango Phone

Assume we are navigating to a page called Page1.xaml from the secondary tile.

image

A common requirement you may come across to delete the secondary tiles once user has navigated to the application page.

Essentially you need to perform two steps

  1. Query for the secondary tile and delete it
  2. Perform delete operation on OnNavigatedTo function of application page

Function to delete the tile


private void DeleteTile()
        {
            var uri = new Uri("/Page1.xaml?state= Live Tile", UriKind.Relative);
            ShellTile tileToUpdate = ShellTile.ActiveTiles.Where(t => t.NavigationUri == uri).FirstOrDefault();
            tileToUpdate.Delete();

        }


Simply we are querying for the tile and then deleting it.

Calling it to OnNavigatedTo function


 protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
        {
            DeleteTile();
        }


This was all required to delete secondary tiles.

I hope this post was useful. Thanks for reading Smile

About Dhananjay Kumar

Dhananjay Kumar is Developer, Blogger , Speaker, Learner , Mindcracker & Microsoft MVP.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Join 1,380 other followers

Tweets

Categories

Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my current or previous employer's view in anyway. © Copyright 2012