简体   繁体   中英

How can I update the live tile while the program is not running?

I've been strugling a couple of days. I'm making a local weather app and I want the tile to show a image (weathericon), and text (name of the place + temperature).

In code you could do:

ShellTile firstTile = ShellTile.ActiveTiles.First();
var newData = new StandardTileData()
{
    Title = "Placename, 50F",
    BackgroundImage = new Uri("background.png", UriKind.Relative),
};

// Update the default tile
firstTile.Update(newData);

But how do you do this while the app is not running, so I dont have to open the application to update the tile, but it does it by itself.

You will need to set up a BackgroundAgent to do this. Jeff Blankenburg has a good tutorial on doing this at http://www.jeffblankenburg.com/2011/11/25/31-days-of-mango-day-25-background-agents/

A couple caveats:

  • You can't control when it runs.

  • Your images need to be hosted externally (eg not resources/content of the app). Ku6opr says that images can be generated via code and placed into /Shared/ShellContent as an alternative.

  • Images need to be 173x173 pixels

  • Images need to be less than 85K in size.

edit: fixed pixel size. was going from memory, and apparently those bits were fried

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM