Вопрос

When I get any and when I get more than one push messages (so in any cases) this methode shows always "1".

  private void Application_Activated(object sender, ActivatedEventArgs e)
            {
                List<ShellTile> pinnedtiles = ShellTile.ActiveTiles.ToList();
                MessageBox.Show(pinnedtiles.Count().ToString());

            }

How I have testing this: I start my application, than I go into background, sent some push messages, the number of new messages is more than one, than I activate my application and in message box I got the same number - 1 (but on Tile icon I have more)

When I start first my application , before I have recieved any push messages, I have the same result (1)

What I am doing wrong?

UPDATED:

In this post it works:

Distinct normal launch with push notification Windows Phone 7

UPDATED: There is no Count property:

  MessageBox.Show(ShellTile.ActiveTiles.First().Count.ToString());

UPDATED: Is there any other way to get count from Tile?

Это было полезно?

Решение

ShellTile does not allow you to read the values only to update them (using Update method). As someone suggested in the comments above, I would make your app the source of the data rather than trying to read it from the shelltile.

I would do something like this:

ViewModel - Saved to isolated storage on application exit / unload / whenever:

public int OutstandingNotification{ get; set;}

BackgroundTask for updating the Live tile based on notifications:

tile.Update(new StandardTileData { Count = App.ViewModel.OutstandingNotification}

Application Load - Loads the ViewModel from isolated storage and displays the value:

MessageBox.Show(App.ViewModel.OutstandingNotification.ToString());
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top