Advanced Live Tiles, Part 3: Lock Screens: Listing 3

The SendTile_Click event handler.

private void SendTile_Click(object sender, RoutedEventArgs e)
{
    string tile = (String.Format("<tile><visual><binding template=\"TileWideText01\">" +
              "<text id=\"1\">{0}</text>" +
              "<text id=\"2\"> </text>" +
            "</binding>" +
            "<binding template=\"TileSquareText03\">" +
              "<text id=\"1\">{0}</text>" +
              "<text id=\"2\"> </text>" +
            "</binding>" +
          "</visual>" +
        "</tile>", Message.Text));
    XmlDocument xmlDoc = new XmlDocument();
    xmlDoc.LoadXml(tile);
    TileNotification tileNotification = new TileNotification(xmlDoc);
    TileUpdateManager.CreateTileUpdaterForApplication().Update(tileNotification);
    Status.Text = "Lock Screen Tile was sent.";
}

About the Author

Eric Vogel is a Sr. Software Developer at Kunz, Leigh, & Associates in Okemos, MI. He is the president of the Greater Lansing User Group for .NET. Eric enjoys learning about software architecture and craftsmanship, and is always looking for ways to create more robust and testable applications. Contact him at vogelvision@gmail.com.