locked
Pin Application Tile (Primary Tile) to Start Windows Phone 8 RRS feed

  • Question

  • I am using Windows Phone 8 SDK with C# and was wondering how to pin the application time (primary tile) to the start screen from code.  I know the user can do this manually but I want to do it from a press of a button if the user wants to.  I know I can do this with secondary tiles but I am after a way to do this from code for the primary tile.  Thanks.
    Saturday, November 24, 2012 10:47 AM

Answers

  • Hi,

    sorry for late reply.

    >>So are you saying that there are 2 primary tiles now?

    No, not exactly.

    >>So if I update the primary tile from code, does that update both tiles

    No, it will just update the one add to start by "pin to start"

    >>Is there any code that will just let me carry out the "pin to start" functionality so that the user does not pin another tile?

    Primary tile all been then, Windows phone SDK doesn't provide API to create it, that means you want funcationality like "pin to start" , you need try this live tile.

    Best Regards


    Mark Yu - MSFT
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Marked as answer by GettingHelp Thursday, December 13, 2012 2:37 AM
    Monday, December 10, 2012 1:09 PM
    Moderator

All replies

  • Hi,

    Please use those code:

                StandardTileData standardTileData = new StandardTileData();
                standardTileData.BackgroundImage = null;
                standardTileData.Title = "Pinned by button";
                standardTileData.Count = 26;
                standardTileData.BackTitle = "Pinned";
                standardTileData.BackContent = "Tile";
                standardTileData.BackBackgroundImage = null;
                ShellTile tiletopin = ShellTile.ActiveTiles.FirstOrDefault(x => x.NavigationUri.ToString().Contains("MainPage.xaml"));
                if (tiletopin == null)
                {
                    ShellTile.Create(new Uri("/MainPage.xaml", UriKind.Relative), standardTileData);
                }
                else
                {
                    MessageBox.Show("Already Pinned");
                }
    Best Regards

    • Edited by iwpfModerator Monday, December 3, 2012 1:02 AM
    • Proposed as answer by iwpfModerator Wednesday, December 5, 2012 1:31 AM
    • Marked as answer by iwpfModerator Thursday, December 6, 2012 1:09 AM
    • Unmarked as answer by GettingHelp Thursday, December 6, 2012 10:47 PM
    Tuesday, November 27, 2012 11:46 AM
    Moderator
  • That is for a secondary tile though not primary tile yes?
    Friday, November 30, 2012 10:44 AM
  • No, it is not secondary tile.

    Best Regards


    Mark Yu - MSFT
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Tuesday, December 4, 2012 6:12 AM
    Moderator
  • Have you tried it on Windows Phone 8?  The user presses a button and the application tile is pinned to the start screen...that is the functionality I am after.  I tried the above and it does not work.
    • Edited by GettingHelp Wednesday, December 5, 2012 2:43 AM Changes
    Wednesday, December 5, 2012 2:41 AM
  • Hi,

    I have tried this on Windows Phone 8. This code is quite simple, just put those code into a button click event and run, the screenshot as below:

    Best Regards


    Mark Yu - MSFT
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Wednesday, December 5, 2012 6:03 AM
    Moderator
  • So now if you go to the next screen and hold down your finger under a context menu appears on the application...do you have the option to "pin to start"? Your code works as you say but you can still go to the list of applications, find the application you want to pin, hold your finger down on the application name, select "pin to start" from the context menu and you will be able to get another tile pinned (this is the application tile right?)
    Wednesday, December 5, 2012 8:15 AM
  • Hi,

    Actually they are same, I just didn't set the background image

                StandardTileData standardTileData = new StandardTileData();
    
    
                standardTileData.BackgroundImage = new Uri("ApplicationIcon.png", UriKind.Relative);
                    
                standardTileData.Title = "Pinned by button";
                standardTileData.Count = 26;
                standardTileData.BackTitle = "Pinned";
                standardTileData.BackContent = "Tile";
                standardTileData.BackBackgroundImage = null;
    
    
    
                ShellTile tiletopin = ShellTile.ActiveTiles.FirstOrDefault(x => x.NavigationUri.ToString().Contains("MainPage.xaml"));
    
    
                if (tiletopin == null)
                {
                    ShellTile.Create(new Uri("/MainPage.xaml", UriKind.Relative), standardTileData);
                }
                else
                {
                    MessageBox.Show("Already Pinned");
                }


    There are two tiles in the screen, one created by the button click, another one by "pin to start"

    Best Regards


    Mark Yu - MSFT
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.


    Wednesday, December 5, 2012 12:18 PM
    Moderator
  • So are you saying that there are 2 primary tiles now?

    So if I update the primary tile from code, does that update both tiles?  Id no, which one does it update?

    Is there any code that will just let me carry out the "pin to start" functionality so that the user does not pin another tile?

    Thursday, December 6, 2012 2:51 AM
  • Had to unmark as answer as I had a few more questions...not sure what the correct way is to do this!
    Thursday, December 6, 2012 10:48 PM
  • Hi,

    sorry for late reply.

    >>So are you saying that there are 2 primary tiles now?

    No, not exactly.

    >>So if I update the primary tile from code, does that update both tiles

    No, it will just update the one add to start by "pin to start"

    >>Is there any code that will just let me carry out the "pin to start" functionality so that the user does not pin another tile?

    Primary tile all been then, Windows phone SDK doesn't provide API to create it, that means you want funcationality like "pin to start" , you need try this live tile.

    Best Regards


    Mark Yu - MSFT
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Marked as answer by GettingHelp Thursday, December 13, 2012 2:37 AM
    Monday, December 10, 2012 1:09 PM
    Moderator
  • I did not think there was such functionality...Just have to ask user to pin it themselves :)

    Thanks.

    Thursday, December 13, 2012 2:37 AM
  • Hie.. thanks for posting i need small info. when user already pin the primary tile from "pin to start" then when i run app my application creates secondary tile it seems two tiles pinning. is it possible to handle the tiles pinning. will u help me on this please. i want only one tile on my start.
    Saturday, December 15, 2012 9:25 AM
  • Hie.. thanks for posting i need small info. when user already pin the primary tile from "pin to start" then when i run app my application creates secondary tile it seems two tiles pinning. is it possible to handle the tiles pinning. will u help me on this please. i want only one tile on my start.
    Saturday, December 15, 2012 9:26 AM
  • Hi,

    Actually they are same, I just didn't set the background image

                StandardTileData standardTileData = new StandardTileData();
    
    
                standardTileData.BackgroundImage = new Uri("ApplicationIcon.png", UriKind.Relative);
                    
                standardTileData.Title = "Pinned by button";
                standardTileData.Count = 26;
                standardTileData.BackTitle = "Pinned";
                standardTileData.BackContent = "Tile";
                standardTileData.BackBackgroundImage = null;
    
    
    
                ShellTile tiletopin = ShellTile.ActiveTiles.FirstOrDefault(x => x.NavigationUri.ToString().Contains("MainPage.xaml"));
    
    
                if (tiletopin == null)
                {
                    ShellTile.Create(new Uri("/MainPage.xaml", UriKind.Relative), standardTileData);
                }
                else
                {
                    MessageBox.Show("Already Pinned");
                }


    There are two tiles in the screen, one created by the button click, another one by "pin to start"

    Best Regards


    Mark Yu - MSFT
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.


    Very useful, marking it... thanks buddy!

    RainCast Lab - http://www.windowsphone.com/en-US/publishers/raincast

    Wednesday, August 21, 2013 12:48 PM
  • Update: In Windows 10 UWP, with the Creators Update, you can now pin your primary tile to Start: https://blogs.msdn.microsoft.com/tiles_and_toasts/2017/02/01/primary-live-tile-api-windows-10/
    Wednesday, February 22, 2017 5:32 PM