Working with Windows Phone Application and Secondary Tiles

By changing the image now we can get the Application Tile of desired background image. 3.As we know that we can’t  create an Application tile programmatically but we can modify      it.

4.Following are the steps need to follow.

     >> Lets create an Images folder where we put our all images which will be used in the Tiles   >>inside Images folder we have following images

 *ModifdSecondaryBackTile.png

Note: Make all images BuildActionProperty to “Content”
For Modify an Application Tile  and create a Secondary Tile in the MainPage.xaml add the following code-

  
       
             
               
             
            
            
   
          
      
         
         
         
     
     
    
             
                  
   
 
MainPage.xaml.cs add the following code
 
MainPage.xaml.cs

      //
 public MainPage()     
     {       
      InitializeComponent();
       }
         private void CountSlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs e)      {       
 SliderText.Text = Math.Round(CountSlider.Value, 0).ToString();
        }
    private void imgFirstPrimary_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
    {   
      imgFirstPrimary.Opacity = 1;        imgSecondPrimary.Opacity = .5;
     }
    private void imgSecondPrimary_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
     {  
       imgSecondPrimary.Opacity = 1;     
       imgFirstPrimary.Opacity = .5;
      }
    private void PrimaryButton_Click(object sender, RoutedEventArgs e)
      {       
      ShellTile PrimaryTile = ShellTile.ActiveTiles.First();
         if (PrimaryTile != null)
            {  
            StandardTileData tile = new StandardTileData();
         if (imgFirstPrimary.Opacity == 1)
           tile.BackgroundImage = new Uri("images/FirstPrimaryTile.png", UriKind.Relative);
             else if (imgSecondPrimary.Opacity == 1)    
            tile.BackgroundImage = new Uri("images/SecondPrimaryTile.png", UriKind.Relative);  
           else
               {
                 }         
    tile.Count = (Int32)Math.Round(CountSlider.Value, 0);  
 
            tile.Title = TitleText.Text
       PrimaryTile.Update(tile);       
      }    
     }
      
  private void SecondaryButton_Click(object sender, RoutedEventArgs e)   
  {  
           ShellTile SecondaryTile = ShellTile.ActiveTiles.FirstOrDefault(x => x.NavigationUri.ToString().Contains                    
                  ("DefaultTitle=NewTile"));
        StandardTileData tile = new StandardTileData();    
                  if (SecondaryTile == null)       
  {       
     tile.BackgroundImage = new Uri("images/SecondaryTile.png", UriKind.Relative);   
         tile.Title = "Secondary Tile";   
         tile.BackTitle = "Back side";    
        tile.BackBackgroundImage = new Uri("images/SecondaryBackTile.png", UriKind.Relative);            tile.BackContent = "Back side of Tile";          
          ShellTile.Create(new Uri("/SecondaryTile.xaml?DefaultTitle=NewTile", UriKind.Relative), tile);   
      }  
   }

Note : We have to add a new Item as SecondaryTile.xaml  where we will navigate after clicking the Secondary Tile

Secondary Tiles:

     5. As we have created one secondary Tile we will now update and delete it
Following are the steps

      In SecondaryTile.xaml add the following code

  SecondaryTile.xaml

150 150 Burnignorance | Where Minds Meet And Sparks Fly!