public void setTile(Exercise ex) { string imagePath_Wide = "ms-appx:///assets/tiles_images/wide_tile/" + ex.Title + ".jpg"; string imagePath_Square = "ms-appx:///assets/tiles_images/square_tile/" + ex.Title + ".jpg";; string title = ex.Title; string reps = "Reps: " + ex.Reps; string sets = "Sets: " + ex.Sets; ITileSquare310x310Image tileContent = TileContentFactory.CreateTileSquare310x310Image(); tileContent.Image.Src = imagePath_Square; tileContent.Image.Alt = "image"; // Create a notification for the Wide310x150 tile using one of the available templates for the size. ITileWide310x150PeekImage02 wideTile = TileContentFactory.CreateTileWide310x150PeekImage02(); wideTile.TextHeading.Text = title; wideTile.TextBody2.Text = reps; wideTile.TextBody3.Text = sets; wideTile.Image.Src = imagePath_Wide; // Create a notification for the Square150x150 tile using one of the available templates for the size. ITileSquare150x150PeekImageAndText01 square150x150Content = TileContentFactory.CreateTileSquare150x150PeekImageAndText01(); square150x150Content.Image.Src = imagePath_Square; square150x150Content.TextBody1.Text = title; square150x150Content.TextBody2.Text = reps; square150x150Content.TextBody3.Text = sets; // Create a notification for the Square71x71 tile using one of the available templates for the size. //ITileSquare71x71Image square71x71Content = TileContentFactory.CreateTileSquare71x71Image(); //square71x71Content.Image.Src = imagePath; // Attach the Square71x71 template to the Square150x150 template. //square150x150Content.Square71x71Content = square71x71Content; // Attach the Square150x150 template to the Wide310x150 template. wideTile.Square150x150Content = square150x150Content; // Attach the Wide310x150 to the Square310x310 template. tileContent.Wide310x150Content = wideTile; // Send the notification to the application’s tile. TileUpdateManager.CreateTileUpdaterForApplication().Update(tileContent.CreateNotification()); }
void UpdateLiveTiles() { try { //*********************************************** //Adjust these parameters with appropriate values string mediumImagePath = "/Assets/Logo.png"; string wideImagePath = "/Assets/WideLogo.png"; string mediumText1 = "Level"; // **Don't forget to localise** string mediumText2 = "Score"; string mediumText3 = "Time"; string mediumText4 = "Coins"; string mediumData1 = "99"; // **This data should come from a game class** string mediumData2 = "1234"; string mediumData3 = DateTime.Now.ToString("HH:mm:ss", System.Globalization.CultureInfo.InvariantCulture); string mediumData4 = "7"; string wideText1 = mediumText1; // **These can be made different if more detail is wanted for wide tile ** string wideText2 = mediumText2; string wideText3 = mediumText3; string wideText4 = mediumText4; string wideData1 = mediumData1; string wideData2 = mediumData2; string wideData3 = mediumData3; string wideData4 = mediumData4; // //*********************************************** // Using NotificationsExtensions library to build up tile content // Choose the tile templates to use for 150x150, 310x150 and 310x310 sizes // Check this link for the tile catalog for Windows Store and Windows Phone: // https://msdn.microsoft.com/en-us/library/windows/apps/hh761491.aspx var mediumTile = TileContentFactory.CreateTileSquare150x150PeekImageAndText01(); var wideTile = TileContentFactory.CreateTileWide310x150PeekImage02(); var largeTile = TileContentFactory.CreateTileSquare310x310SmallImageAndText01(); // Set the branding value for the tiles (weather or not to display the app name) mediumTile.Branding = TileBranding.None; wideTile.Branding = TileBranding.None; largeTile.Branding = TileBranding.Name; //Set the tile template images mediumTile.Image.Src = mediumImagePath; wideTile.Image.Src = wideImagePath; largeTile.Image.Src = mediumImagePath; //Set the tile template text values mediumTile.TextHeading.Text = string.Format("{0}: {1}", mediumText1, mediumData1); mediumTile.TextBody1.Text = string.Format("{0}: {1}", mediumText2, mediumData2); mediumTile.TextBody2.Text = string.Format("{0}: {1}", mediumText3, mediumData3); mediumTile.TextBody3.Text = string.Format("{0}: {1}", mediumText4, mediumData4); wideTile.TextHeading.Text = string.Format("{0}: {1}", wideText1, wideData1); wideTile.TextBody1.Text = string.Format("{0}: {1}", wideText2, wideData2); wideTile.TextBody2.Text = string.Format("{0}: {1}", wideText3, wideData3); wideTile.TextBody3.Text = string.Format("{0}: {1}", wideText4, wideData4); wideTile.TextBody4.Text = string.Empty; largeTile.TextHeading.Text = string.Format("{0}: {1}", wideText1, wideData1); largeTile.TextBodyWrap.Text = string.Format("{0}: {1} - {2}: {3}", wideText2, wideData2, wideText4, wideData4); largeTile.TextBody.Text = string.Format("{0}: {1}", wideText3, wideData3); //This merges the tile templates together to create the single xml for all of them wideTile.Square150x150Content = mediumTile; largeTile.Wide310x150Content = wideTile; //Create the tile updater and update the tiles var updater = TileUpdateManager.CreateTileUpdaterForApplication(); //This is dumb... Will fix with an updated library soon var xml = largeTile.GetXml(); var xDoc = new XmlDocument(); xDoc.LoadXml(xml.ToString()); TileNotification tileNotification = new TileNotification(xDoc); updater.Update(tileNotification); // Reading the actual Xml to understand what is happening here. Debug.WriteLine(xml.ToString()); } catch (Exception ex) { Debug.WriteLine(ex); if (ExceptionLogger.IsEnabled) { ExceptionLogger.Send(ex); } } }