The Windows Phone 7 Live Tile Push Notification Service allows an application to dynamically set the background, title, and count of a live tile when the application is pinned to the main screen. By default the Title is set through the Application Properties in Visual Studio, or by manually editing the <Title> element in Application Manifest file WMAppManifest.xml. Manual editing may be necessary as Visual Studio may prevent some Title values.
In general this is a pretty good mechanism, but there are a number of problems that may complicate a developer attempting to customize their Tile:
- The Title is rendered in a White font, if the background image is bright it may make the Title very hard to read. For example, map road imagery and some pictures.
- The application’s background image is a distinctive logo or contains the application name in a custom trademarked font. For example the Facebook “F” logo.
- The information communicated in the Title is no longer relevant and there is no new status.
- Aesthetically, the Title placement is just wrong.
All of these points, and others, may lead a developer with the desire to either have a blank Title or, as appropriate, clear the Title. Unfortunately a number of factors can make this difficult, the first is that Visual Studio will not allow you to use an empty string in the Application Properties, but as discussed above this can be worked around by manually editing the manifest.
However, there have been recent reports that the App Marketplace is enforcing section 4.1.1(b) of the Windows Phone Application Certification Requirements:
“The <Title> element in the WMAppManifest.xml file must contain the application title. The <Title> element must not be empty. The Application title entered in Step 2 of the submission process to Windows Phone Marketplace and the title displayed on the phone must be the same.”
Thus you must have a default Title on your Tile. This requirement fails to take into account strongly branded background images and the ineffectiveness of this requirement when the application sends a push notification overwriting the Title on the first use of the application.
All of this goes back to the base question, how do I clear an existing Title on my Tile? The obvious answer would be to simply push a notification with an empty Title, but that will not work because of the following documented behavior:
“If this [Title] value is not set, the already-existing Title will display in the Tile.”
My experiments have shown that the definition of “is not set” means empty or all whitespace (String.IsNullOrWhiteSpace(Title)), thus using spaces will not work. Some have solved the problem by creating a background image that has white (or light) color in the lower left corner and then send one of the smallest character strings, a single period (“.”).
But I have found a perfect solution. Fortunately .Net strings are all built around Unicode characters which gives us a lot of code points that we can use. Unicode designates a number of code points as whitespace and the .Net Char.IsWhiteSpace uses those designated code points (and others) to implement String.Trim and String.IsNullOrWhiteSpace (Note: the definition changed slightly between 3.5 and 4.0). So what is a code point that will have a blank glyph but will not be considered whitespace? The “Zero-Width Non Joiner” or U+200C, what this code point is used for is interesting but beyond this write up.
So how have I used this? In the Push Notification Service I have been experimenting with I have a method that converts a Title, Count, and Background Uri into the proper XML Push payload. In that method I simply check for an whitespace string and replace it with a ZWNJ string:
const string EmptyTitle = “\u200c”; // Zero-Width Non Joiner
title = EmptyTitle;
Now as needed, I can clear the Title on a Live Tile through a push notification!