Reputation: 433
so I used the following code to create a simple tile. under this.InitializeComponent();
var tileCon = TileUpdateManager.GetTemplateContent(TileTemplateType.TileSquareBlock); var tileLines = tileCon.SelectNodes("tile/visual/binding/text"); tileLines[0].InnerText = "hell"; tileLines[1].InnerText = "hi"; var notification = new TileNotification(tileCon); var updater = TileUpdateManager.CreateTileUpdaterForApplication(); updater.Update(notification); </code>
first time I run the app, the tile appears. But if I unpin the tile from the Metro UI no matter how many times I run the app, it will never show again. But I want it to add a new tile every time
Upvotes: 0
Views: 432
Reputation: 5225
I think you may be confusing the concepts of live tiles and secondary tiles. (To make it even more confusing, secondary tiles can be live too.) :) The code above implements the notion of a "live tile"...pushing a notification to an existing tile to update its text/image.
You state that you want to "add a new tile every time". Adding a new tile to the Start Menu from your application is the notion of a "secondary tile"...it is not your main application's tile, but rather an additional tile that, when launched, that take you straight to a specific subsection of your application. For example, on a Weather app which has a hub of cities and then detail pages for the weather of each city, you could pin a secondary tile for the weather of the city you live in (say it's New York City). Then clicking on that NYC secondary tile in the Start Menu would launch the application and take you straight to the weather page for New York City (bypassing the hub page).
Finally, we don't have the power to create additional tiles without the end user's okay. So even if you implement the secondary tile code, you should get the end user's confirmation before creating a new tile. I can't imagine a scenario when you would want to always create a new tile in your InitializeComponent; could you give some more detail on what you are trying to do?
Here are some resources with code samples:
Upvotes: 1
Reputation: 23754
Once the user has unpinned the tile, your application won't be able to programmatically put it back - it's up to the user to repin.
Upvotes: 1