Introduction
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;
using namespace Windows::UI::Notifications;
using namespace Windows::Data::Xml::Dom;
MainPage::MainPage()
{
InitializeComponent();
}
void MainPage::OnNavigatedTo(NavigationEventArgs^ e)
{
(void) e; }
void LiveTileFun::MainPage::DemoTile1
(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
{
XmlDocument^ tileXml =
TileUpdateManager::GetTemplateContent(TileTemplateType::TileSquareImage);
XmlNodeList^ tileImageAttributes = tileXml->GetElementsByTagName("image");
static_cast<XmlElement^>(tileImageAttributes->Item(0))->
SetAttribute("src", "ms-appx:///Assets/Winner150.png");
TileNotification^ tileNotification = ref new TileNotification(tileXml);
TileUpdateManager::CreateTileUpdaterForApplication()->Update(tileNotification);
}