Click here to Skip to main content
13,089,433 members (62,270 online)
Click here to Skip to main content
Add your own
alternative version


Posted 11 Sep 2012

Super Simple Live Tile Notification Using an Image (C++)

, 11 Sep 2012
Rate this:
Please Sign up or sign in to vote.
This sample demonstrates how to use the Tile Template, specifically the TileSquareImage and an image.


This sample demonstrates how to use the Tile Template, specifically the TileSquareImage and an image.

Using the Code

Unzip the file, run the solution.

The solution will run a Windows 8 application with no snap/fill/full features.

To see it working, make sure to use the Windows/flag key to switch to the start screen, find your icon and then hit the flag to go back to the running application. 

Click the button and then use the Windows/flag key again, quickly, and you will see the new image appear. (And yes, this is a variation on an earlier tip.)

For more information, see my blog.

#include "pch.h"
#include "MainPage.xaml.h"

using namespace LiveTileFun;
using namespace Platform;
using namespace Windows::Foundation;
using namespace Windows::Foundation::Collections;
using namespace Windows::UI::Xaml;
using namespace Windows::UI::Xaml::Controls;
using namespace Windows::UI::Xaml::Controls::Primitives;
using namespace Windows::UI::Xaml::Navigation;
//Add the next two lines 
using namespace Windows::UI::Notifications;
using namespace Windows::Data::Xml::Dom;


void MainPage::OnNavigatedTo(NavigationEventArgs^ e)
	(void) e;	// Unused parameter

void LiveTileFun::MainPage::DemoTile1
	(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
	//This line can remain the same, except for the template, in this case TileSquareImage
	//If you use the wrong template, then an error is thrown
	XmlDocument^ tileXml = 
	// This line changes, now you look for the default tag of image, tileImageAttribute is
	// a variable that I created or took from an example, it is not a keyword
        XmlNodeList^ tileImageAttributes = tileXml->GetElementsByTagName("image");
	//*****************************	// the static_cast is used to move 
	// the image in to the element Item 0 or the first item
	// in this case, you only get a single item, so you must use item 0, otherwise you get an
	// error
					SetAttribute("src", "ms-appx:///Assets/Winner150.png"); 
// Send your tile notification and then update it, this code did not change
// It would change if you modify the XmlDocument variable titleXml
TileNotification^ tileNotification = ref new TileNotification(tileXml);


This article, along with any associated source code and files, is licensed under The Microsoft Public License (Ms-PL)


About the Author

sam stokes
Instructor / Trainer Microsoft
United States United States
Sam Stokes works for Microsoft as a technology evangelist and is focused on working with colleges, students and professors.

You may also be interested in...


Comments and Discussions

-- There are no messages in this forum --
Permalink | Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.170813.1 | Last Updated 12 Sep 2012
Article Copyright 2012 by sam stokes
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid