webdad3
webdad3

Reputation: 9080

WP7 -Live Tiles - Count Value (number in circle) - Mango

I have a function that I'm calling that basically returns a string. If the string = "OVER DUE!" I want to display an alert on the main tile (a number inside a circle). However, if the user corrects this problem I want to clear that tile and just show a normal tile with no number.

The code below does what I want it to do the 1st time it checks. So if I get an "OVER DUE!" everything works great. But if I correct it, the second tile updates but the main tile still has the number inside the circle. What do I need to do to clear the main tile back to its original state?

I would also like to clean up this code as it really is duplicated. Does anyone have any suggestions how I can write 1 function to do what I want?

            if (nextDateCheck != "OVER DUE!")
            {

                var standardTile = new StandardTileData
                {
                    Title = "Change your Oil",
                    BackgroundImage = new Uri("w7ChangeYourOil_icon_transparent.png", UriKind.Relative),
                    BackTitle = "Next Oil Change",
                    BackContent = "Your next Oil Change is: " + nextDateCheck.ToString()
                };
                appTile.Update(standardTile);
            }
            else
            {
                var standardTile = new StandardTileData
                {
                    Title = "Change your Oil",
                    BackgroundImage = new Uri("w7ChangeYourOil_icon_transparent.png", UriKind.Relative),
                    Count = 1, // any number can go here, leaving this null shows NO number   
                    BackTitle = "Next Oil Change",
                    BackContent = "Your next Oil Change is: " + nextDateCheck.ToString()
                };
                appTile.Update(standardTile);
            }

Upvotes: 0

Views: 481

Answers (1)

Darkside
Darkside

Reputation: 1739

The answer is quite simple really.

You need to set the Tile count back to 0 when you want to unset the number graphic on the front of the tile.

Reason being it's due to the way the original framework used to be Push Notification driven only which the new Local Tile framework still has to support.

The Title, Front Image and count are still overlays on top of the new programmatic tile options.

Hope this helps

Upvotes: 1

Related Questions