ARTICLE

Live Tiles in Windows Phone 7.5 or Mango phone

Posted by Dhananjay Kumar Articles | Windows Phone 8 September 14, 2011
In Windows Phone 7 Live tiles was only possible through Push notification. However Windows Phone 7.5 (code name: Mango) allows developers to update, create primary and secondary tiles without push notifications.
Reader Level:

In Windows Phone 7 Live tiles was only possible through Push notification. However Windows Phone 7.5 (code name: Mango) allows developers to update, create primary and secondary tiles without push notifications. In this post, we will walkthrough the process.

Live Tiles in Windows Phone 7.5 or Mango phone

To create and update live tiles essentially you need to work with the below classes

ShellTile

StandardTileData


You can get the instance of current tile for an application as below,

Live Tiles in Windows Phone 7.5 or Mango phone

You can set the data for tile as below,

Live Tiles in Windows Phone 7.5 or Mango phone

StandardTileDataclass has following properties. You can set value of these properties to set the data of live tiles.

  1. public Uri BackBackgroundImage
  2. public string BackContent
  3. public Uri BackgroundImage
  4. public string BackTitle
  5. public int? Count

Update a Live Tile

The below code snippet will update a live tile with title and count.

using System.Linq;

using Microsoft.Phone.Controls;
using
Microsoft.Phone.Shell;
using
WindowsPhoneApplication3; 

namespace liveTiles

{
    public partial class MainPage :
PhoneApplicationPage

    {

       
// Constructor

        public MainPage()

        {

            InitializeComponent();

            UpdateLiveTiles();

          }      

          private void UpdateLiveTiles()

        {
            ShellTile currentTiles = ShellTile.ActiveTiles.First();
            vartiles UpdatedData = new StandardTileData
            {
                Title = "Live Tiles ",
                Count = 10,
                BackTitle = "Back Title" 
            };

            currentTiles.Update(tilesUpdatedData); 
        }       
    }
}


Live tile will get updated as below,

Live Tiles in Windows Phone 7.5 or Mango phone

Create a Live Tile

The below code snippet will create a new live tile. Creation of live tile is exactly same as updating of live tile but to call Create function.

        private void CreateLiveTile()
        {
            var newTile = new StandardTileData() 
            { 
                Title = "Blogs Update",
                BackgroundImage = new Uri("background.png"UriKind.Relative),
                Count = 42,
            };
            var uri = "/LiveTileUserControl.xaml?state= Live Tile";
            ShellTile.Create(new Uri(uri, UriKind.Relative), newTile);
        }


Important point to note in the above code snippet is the uri. On click of create live tile user will navigate to given XAML.

Live Tiles in Windows Phone 7.5 or Mango phone

Updating created Live Tile

To update a particular tile, first you need to fetch the tile with a query string as below,

       
private void UpdatingCreatedTile()
        {
            var uri = new Uri("/LiveTileUserControl.xaml?state= Live Tile"UriKind.Relative);
            ShellTile  tileToUpdate = ShellTile.ActiveTiles.Where(t => t.NavigationUri == uri).FirstOrDefault();
            var tilesUpdatedData = new StandardTileData
            {
                Title = "Created Tiles Updated ",
                Count = 45,
                BackTitle = "Back Title"

            };

            tileToUpdate.Update(tilesUpdatedData);
        }

Tile will get updated as below,

Live Tiles in Windows Phone 7.5 or Mango phone

This was all about basic of live tiles in Windows Phone 7.5 without using push notifications.

I hope this post was useful. Thanks for reading.

Login to add your contents and source code to this article
post comment
     

very basic use of Live Tiles are to provide notifications to users. In Windows Phone 7 live tiles was only possible via PUSH NOTIFICATIONS whereas in Mango u can have live tiles without that as well.

Posted by Dhananjay Kumar Sep 15, 2011

Hi,dhananjay, It was nice article,but can u tell me what is the basic use of Live Tiles in Window Phone7

Posted by Shweta Kuthi Sep 15, 2011
COMMENT USING
PREMIUM SPONSORS
Over-C is a holistic consortium of communications and technology specialists. We build, deploy and market both business as well as consumer products and solutions.
Get Career Advice from Experts
SPONSORED BY
  • PDF reports have never been easier to create. With our included WYSIWYG Designer, you can layout your reports, set up your data source and let DynamicPDF ReportWriter do the rest.
Join a Chapter