/// <summary> /// This is the click handler for the 'Update logo async' button. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private async void UpdateDefaultLogo_Click(object sender, RoutedEventArgs e) { Button button = sender as Button; if (button != null) { if (Windows.UI.StartScreen.SecondaryTile.Exists(MainPage.logoSecondaryTileId)) { // Add the properties we want to update (logo in this example) SecondaryTile secondaryTile = new SecondaryTile(MainPage.logoSecondaryTileId); secondaryTile.VisualElements.Square150x150Logo = new Uri("ms-appx:///Assets/squareTileLogoUpdate-sdk.png"); bool isUpdated = await secondaryTile.UpdateAsync(); if (isUpdated) { rootPage.NotifyUser("Secondary tile logo updated.", NotifyType.StatusMessage); } else { rootPage.NotifyUser("Secondary tile logo not updated.", NotifyType.ErrorMessage); } } else { rootPage.NotifyUser("Please pin a secondary tile using scenario 1 before updating the Logo.", NotifyType.ErrorMessage); } } }
public static async void UpdateSecondaryTile(string guid, string text, string icon, string imgSrc150x150, string imgSrc310x150, string imgSrc310x310) { if (Windows.UI.StartScreen.SecondaryTile.Exists(guid)) { SecondaryTile secondaryTile = new SecondaryTile(guid); secondaryTile.VisualElements.Square150x150Logo = new Uri(imgSrc150x150); secondaryTile.VisualElements.ShowNameOnSquare150x150Logo = true; secondaryTile.VisualElements.Wide310x150Logo = new Uri(imgSrc310x150); secondaryTile.VisualElements.ShowNameOnWide310x150Logo = true; secondaryTile.VisualElements.Square310x310Logo = new Uri(imgSrc310x310); secondaryTile.VisualElements.ShowNameOnSquare310x310Logo = true; bool isUpdated = await secondaryTile.UpdateAsync(); } else { // During creation of secondary tile, an application may set additional arguments on the tile that will be passed in during activation. // These arguments should be meaningful to the application. In this sample, we'll pass in the date and time the secondary tile was pinned. string tileActivationArguments = guid + " TabWasPinnedAt=" + DateTime.Now.ToLocalTime().ToString(); // Create a Secondary tile with all the required arguments. // Note the last argument specifies what size the Secondary tile should show up as by default in the Pin to start fly out. // It can be set to TileSize.Square150x150, TileSize.Wide310x150, or TileSize.Default. // If set to TileSize.Wide310x150, then the asset for the wide size must be supplied as well. // TileSize.Default will default to the wide size if a wide size is provided, and to the medium size otherwise. SecondaryTile secondaryTile = new SecondaryTile(guid, text, tileActivationArguments, new Uri(imgSrc150x150), TileSize.Square150x150); secondaryTile.BackgroundColor = Windows.UI.Colors.Black; secondaryTile.VisualElements.ShowNameOnSquare150x150Logo = true; secondaryTile.VisualElements.Wide310x150Logo = new Uri(imgSrc310x150); secondaryTile.VisualElements.ShowNameOnSquare150x150Logo = true; secondaryTile.VisualElements.Square310x310Logo = new Uri(imgSrc310x310); secondaryTile.VisualElements.ShowNameOnWide310x150Logo = true; bool isPinned = await secondaryTile.RequestCreateAsync(); } }
public static async Task UpdateHelper(SecondaryTile tile, TileHelper notification) { if (tile.TileId == "____dummyApplicationTile") { Windows.UI.Notifications.TileUpdateManager.CreateTileUpdaterForApplication().Update(notification.GetNotificacion()); BadgeUpdateManager.CreateBadgeUpdaterForApplication().Update(notification.GetBadge()); } else { tile.VisualElements.BackgroundColor = notification.BackgroundColor != null ? notification.BackgroundColor : tile.VisualElements.BackgroundColor; tile.DisplayName = (notification.Title != null && notification.Title != "") ? notification.Title : tile.DisplayName; Windows.UI.Notifications.TileUpdateManager.CreateTileUpdaterForSecondaryTile(tile.TileId).Update(notification.GetNotificacion()); BadgeUpdateManager.CreateBadgeUpdaterForSecondaryTile(tile.TileId).Update(notification.GetBadge()); await tile.UpdateAsync(); } }
private async Task<bool> CreateOrUpdateSecondaryTileAsync(SecondaryTile tile, TileVisualOptions options) { if (tile == null) return false; tile.VisualElements.ShowNameOnSquare150x150Logo = true; tile.VisualElements.Square71x71Logo = options.Square71x71Logo ?? null; tile.VisualElements.Square150x150Logo = options.Square150x150Logo ?? null; if (!(ApiInformation.IsTypePresent(("Windows.Phone.UI.Input.HardwareButtons")))) { tile.VisualElements.Wide310x150Logo = options.Wide310x150Logo ?? null; tile.VisualElements.Square310x310Logo = options.Square310x310Logo ?? null; tile.VisualElements.ShowNameOnWide310x150Logo = true; tile.VisualElements.ShowNameOnSquare310x310Logo = true; } if (SecondaryTile.Exists(tile.TileId)) { return await tile.UpdateAsync(); } else { if (!ApiInformation.IsTypePresent(("Windows.Phone.UI.Input.HardwareButtons"))) { if (options.Rect == null) return await tile.RequestCreateAsync(); else return await tile.RequestCreateForSelectionAsync(options.Rect, options.PopupPlacement); } else if (ApiInformation.IsTypePresent(("Windows.Phone.UI.Input.HardwareButtons"))) { // OK, the tile is created and we can now attempt to pin the tile. // Since pinning a secondary tile on Windows Phone will exit the app and take you to the start screen, any code after // RequestCreateForSelectionAsync or RequestCreateAsync is not guaranteed to run. For an example of how to use the OnSuspending event to do // work after RequestCreateForSelectionAsync or RequestCreateAsync returns, see Scenario9_PinTileAndUpdateOnSuspend in the SecondaryTiles.WindowsPhone project. return await tile.RequestCreateAsync(); } } return false; }
private async void Pin() { if (this.Group == null) { return; } string tileID = $"Tile_Group_{this.GroupID}"; string argument = $"GroupDetail-{this.GroupID}"; SecondaryTile tile = new SecondaryTile(tileID, this.Group.Name, argument, new Uri("ms-appx:///Assets/logo-50.png"), TileSize.Square150x150); await tile.RequestCreateAsync(); TileBindingContentAdaptive bindingContent = new TileBindingContentAdaptive() { PeekImage = new TilePeekImage() { Source = new TileImageSource(this.Group.LargeAvatar) } }; bindingContent.Children.Add(new TileText { Text = this.Group.Name, Wrap = true, Style = TileTextStyle.Body }); TileBinding binding = new TileBinding() { Branding = TileBranding.NameAndLogo, DisplayName = this.Group.Name, Content = bindingContent }; TileContent content = new TileContent() { Visual = new TileVisual() { TileMedium = binding, TileWide = binding, TileLarge = binding } }; var notification = new TileNotification(content.GetXml()); var updater = TileUpdateManager.CreateTileUpdaterForSecondaryTile(tileID); updater.Update(notification); bool result = await tile.UpdateAsync(); }