private async void UpdateMedium(TileBindingContentAdaptive mediumContent) { TileContent content = new TileContent() { Visual = new TileVisual() { TileMedium = new TileBinding() { Content = mediumContent } } }; try { TileUpdateManager.CreateTileUpdaterForSecondaryTile("SecondaryTile").Update(new TileNotification(content.GetXml())); } catch { SecondaryTile tile = new SecondaryTile("SecondaryTile", "Example", "args", new Uri("ms-appx:///Assets/Logo.png"), TileSize.Default); tile.VisualElements.ShowNameOnSquare150x150Logo = true; tile.VisualElements.ShowNameOnSquare310x310Logo = true; tile.VisualElements.ShowNameOnWide310x150Logo = true; tile.VisualElements.BackgroundColor = Colors.Transparent; await tile.RequestCreateAsync(); TileUpdateManager.CreateTileUpdaterForSecondaryTile("SecondaryTile").Update(new TileNotification(content.GetXml())); } }
public static void CreateRecentActvityLiveTile(Feed feed) { TileBindingContentAdaptive bindingContent; if (feed.SmallImageUrl != null) { bindingContent = new TileBindingContentAdaptive() { PeekImage = new TilePeekImage() { Crop = TileImageCrop.None, Overlay = 0, Source = new TileImageSource(feed.SmallImageUrl) }, Children = { new TileText() { Text = feed.Caption, Wrap = true, Style = TileTextStyle.Body } } }; } else { bindingContent = new TileBindingContentAdaptive() { Children = { new TileText() { Text = feed.Caption, Wrap = true, Style = TileTextStyle.Body } } }; } var binding = new TileBinding() { Branding = TileBranding.NameAndLogo, Content = bindingContent }; var content = new TileContent() { Visual = new TileVisual() { TileMedium = binding, TileWide = binding, TileLarge = binding } }; var tileXml = content.GetXml(); var tileNotification = new TileNotification(tileXml); TileUpdateManager.CreateTileUpdaterForApplication().Update(tileNotification); }
private async void ButtonBase_OnClick(object sender, RoutedEventArgs e) { var secondaryTile = new SecondaryTile( "tilePage", "shortname", "displayname", new Uri("ms-appx:///Assets/StoreLogo.png", UriKind.Absolute), TileSize.Default); var success = await secondaryTile.RequestCreateAsync(); if (success) { var tileBindingContentAdaptive = new TileBindingContentAdaptive { Children = { new TileText { Text = "uwp tiles", Style = TileTextStyle.Header }, new TileText { Text = "secondary", Style = TileTextStyle.Body } } }; var tileBinding = new TileBinding { Branding = TileBranding.Name, Content = tileBindingContentAdaptive, DisplayName = "my tile" }; var tileContent = new TileContent { Visual = new TileVisual { TileMedium = tileBinding, TileWide = tileBinding, TileLarge = tileBinding } }; var xmlDoc = tileContent.GetXml(); TileNotification tileNotification = new TileNotification(xmlDoc); var tileUpdaterForSecondaryTile = TileUpdateManager.CreateTileUpdaterForSecondaryTile("tilePage"); tileUpdaterForSecondaryTile.Update(tileNotification); } }
private void Button_Tapped(object sender, TappedRoutedEventArgs e) { var dining = App.MainViewModel.HfsData.resident_dining; var term = App.MainViewModel.TermInfo; var bindingContent = new TileBindingContentAdaptive(); var items = bindingContent.Children; items.Add(new TileText() { Text = $"Balance: ${dining.balance:0.00}", Style = TileTextStyle.Body }); items.Add(new TileText() { Text = $"Days: {term.FullDaysRemaining}", Style = TileTextStyle.Caption }); items.Add(new TileText() { Text = $"Avg/Day: ${dining.balance/term.FullDaysRemaining:0.00}", Style = TileTextStyle.Caption }); var tileBinding = new TileBinding(); tileBinding.Content = bindingContent; tileBinding.DisplayName = "FoodTile"; tileBinding.Branding = TileBranding.NameAndLogo; var content = new TileContent() { Visual = new TileVisual() { TileSmall = tileBinding, TileMedium = tileBinding, TileWide = tileBinding, TileLarge = tileBinding } }; XmlDocument doc = content.GetXml(); var note = new TileNotification(doc); var updater = TileUpdateManager.CreateTileUpdaterForApplication(); updater.Update(note); }
private void ButtonSendTileNotification_Click(object sender, RoutedEventArgs e) { TileBindingContentAdaptive bindingContent = new TileBindingContentAdaptive() { Children = { GenerateEmailGroup("Jennifer Parker", "Photos from our trip"), GenerateEmailGroup("Steve Bosniak", "Want to go out for dinner after Build tonight?") } }; TileBinding binding = new TileBinding() { Content = bindingContent }; TileContent content = new TileContent() { Visual = new TileVisual() { TileMedium = binding } }; DataPackage dp = new DataPackage(); dp.SetText(content.GetContent()); Clipboard.SetContent(dp); return; string xmlAsString = content.GetContent(); TileNotification notification = new TileNotification(content.GetXml()); content.Visual.TileMedium = new TileBinding() { Branding = TileBranding.Logo, Content = new TileBindingContentAdaptive() }; ComboBox comboBox = new ComboBox(); //var tileContent = NotificationsExtensions.GenerateTileContent(); //TileNotification notif = new TileNotification(null); //ITileSquareText01 tileContent = TileContentFactory.CreateTileSquareText01(); }
public static void CreateBookmarkLiveTile(ForumThreadEntity forumThread) { var bindingContent = new TileBindingContentAdaptive() { Children = { new TileText() { Text = forumThread.Name, Style = TileTextStyle.Body }, new TileText() { Text = string.Format("Unread Posts: {0}", forumThread.RepliesSinceLastOpened), Wrap = true, Style = TileTextStyle.CaptionSubtle }, new TileText() { Text = string.Format("Killed By: {0}", forumThread.KilledBy), Wrap = true, Style = TileTextStyle.CaptionSubtle } } }; var binding = new TileBinding() { Branding = TileBranding.NameAndLogo, Content = bindingContent }; var content = new TileContent() { Visual = new TileVisual() { TileMedium = binding, TileWide = binding, TileLarge = binding } }; var tileXml = content.GetXml(); var tileNotification = new TileNotification(tileXml); TileUpdateManager.CreateTileUpdaterForApplication().Update(tileNotification); }
private static TileBinding GetBindingMediumContent(string income, string spending, string earnings) { var content = new TileBindingContentAdaptive { PeekImage = new TilePeekImage { Source = new TileImageSource("Assets/Square150x150Logo.scale-400.png") }, Children = { new TileText { Text = income, Style = TileTextStyle.CaptionSubtle, Wrap = true }, new TileText { Text = spending, Style = TileTextStyle.CaptionSubtle, Wrap = true }, new TileText { Text = earnings, Wrap = true, Style = TileTextStyle.Caption } } }; return new TileBinding { Branding = TileBranding.NameAndLogo, DisplayName = Strings.ApplicationTitle, Content = content }; }
private void button_Click(object sender, RoutedEventArgs e) { var bindingContent = new TileBindingContentAdaptive { PeekImage = new TilePeekImage { Source = new TileImageSource("Assets/Square150x150Logo.png") }, Children = { new TileText { Text = "Hello world", Style = TileTextStyle.Title }, new TileText { Text = "okazuki", Style = TileTextStyle.Body }, } }; var tileBinding = new TileBinding { Branding = TileBranding.NameAndLogo, Content = bindingContent, DisplayName = "Hello display name", }; var content = new TileContent { Visual = new TileVisual { TileSmall = tileBinding, TileMedium = tileBinding, TileLarge = tileBinding, TileWide = tileBinding, } }; var n = new TileNotification(content.GetXml()); TileUpdateManager.CreateTileUpdaterForApplication() .Update(n); }
public static XmlDocument Generate() { // Small content //var smallContent = TileContentFactory.SpecialTemplates.Contact.CreateSmall(); //smallContent.Image = new TileImageSource("http://build2015-tile-polling.azurewebsites.net/assets/hipster.jpg"); var smallContent = new TileBindingContentAdaptive(); // Medium content //var mediumContent = TileContentFactory.Adaptive.CreateMedium(); var mediumContent = new TileBindingContentAdaptive() { TextStacking = TileTextStacking.Center, Children = { new TileText() { Text = "Hi,", Style = TileTextStyle.Base, Align = TileTextAlign.Center }, new TileText() { Text = "MasterHip", Style = TileTextStyle.CaptionSubtle, Align = TileTextAlign.Center } } }; // Wide content var wideContent = new TileBindingContentAdaptive() { Children = { new TileGroup() { Children = { new TileSubgroup() { Weight = 33, Children = { new TileImage() { Source = new TileImageSource("http://build2015-tile-polling.azurewebsites.net/assets/hipster.jpg"), Crop = TileImageCrop.Circle } } }, new TileSubgroup() { TextStacking = TileTextStacking.Center, Children = { new TileText() { Text = "Hi,", Style = TileTextStyle.Title }, new TileText() { Text = "MasterHip", Style = TileTextStyle.SubtitleSubtle } } } } } } }; // Large content var largeContent = new TileBindingContentAdaptive() { TextStacking = TileTextStacking.Center, Children = { new TileGroup() { Children = { // this is for left padding new TileSubgroup() { Weight = 1 }, // this is the image itself new TileSubgroup() { Weight = 2, Children = { new TileImage() { Source = new TileImageSource("http://build2015-tile-polling.azurewebsites.net/assets/hipster.jpg"), Crop = TileImageCrop.Circle } } }, // this is for right padding new TileSubgroup() { Weight = 1 } } }, new TileText() { Text = "Hi,", Style = TileTextStyle.Title, Align = TileTextAlign.Center }, new TileText() { Text = "MasterHip", Style = TileTextStyle.SubtitleSubtle, Align = TileTextAlign.Center } } }; TileContent content = new TileContent() { Visual = new TileVisual() { Branding = TileBranding.Name, TileSmall = new TileBinding() { Content = smallContent }, TileMedium = new TileBinding() { Content = mediumContent }, TileWide = new TileBinding() { Content = wideContent }, TileLarge = new TileBinding() { Branding = TileBranding.NameAndLogo, DisplayName = "Xbox - MasterHip", Content = largeContent } } }; throw new NotImplementedException(); }
public void TestWeatherTile() { TileImageSource backgroundImage = new TileImageSource(BACKGROUND_IMAGE_MOSTLY_CLOUDY); int overlay = 30; TileBindingContentAdaptive smallContent = new TileBindingContentAdaptive() { TextStacking = TileTextStacking.Center, BackgroundImage = new TileBackgroundImage() { Source = backgroundImage, Overlay = overlay }, Children = { new TileText() { Text = "Mon", Style = TileTextStyle.Body, Align = TileTextAlign.Center }, new TileText() { Text = "63°", Style = TileTextStyle.Base, Align = TileTextAlign.Center } } }; TileBindingContentAdaptive mediumContent = new TileBindingContentAdaptive() { BackgroundImage = new TileBackgroundImage() { Source = backgroundImage, Overlay = overlay }, Children = { new TileGroup() { Children = { GenerateMediumSubgroup("Mon", IMAGE_MOSTLY_CLOUDY, 63, 42), GenerateMediumSubgroup("Tue", IMAGE_CLOUDY, 57, 38) } } } }; TileBindingContentAdaptive wideContent = new TileBindingContentAdaptive() { BackgroundImage = new TileBackgroundImage() { Source = backgroundImage, Overlay = overlay }, Children = { new TileGroup() { Children = { GenerateWideSubgroup("Mon", IMAGE_MOSTLY_CLOUDY, 63, 42), GenerateWideSubgroup("Tue", IMAGE_CLOUDY, 57, 38), GenerateWideSubgroup("Wed", IMAGE_SUNNY, 59, 43), GenerateWideSubgroup("Thu", IMAGE_SUNNY, 62, 42), GenerateWideSubgroup("Fri", IMAGE_SUNNY, 71, 66) } } } }; TileBindingContentAdaptive largeContent = new TileBindingContentAdaptive() { BackgroundImage = new TileBackgroundImage() { Source = backgroundImage, Overlay = overlay }, Children = { new TileGroup() { Children = { new TileSubgroup() { Weight = 30, Children = { new TileImage() { Source = new TileImageSource(IMAGE_MOSTLY_CLOUDY) } } }, new TileSubgroup() { Children = { new TileText() { Text = "Monday", Style = TileTextStyle.Base }, new TileText() { Text = "63° / 42°" }, new TileText() { Text = "20% chance of rain", Style = TileTextStyle.CaptionSubtle }, new TileText() { Text = "Winds 5 mph NE", Style = TileTextStyle.CaptionSubtle } } } } }, // For spacing new TileText(), new TileGroup() { Children = { GenerateLargeSubgroup("Tue", IMAGE_CLOUDY, 57, 38), GenerateLargeSubgroup("Wed", IMAGE_SUNNY, 59, 43), GenerateLargeSubgroup("Thu", IMAGE_SUNNY, 62, 42), GenerateLargeSubgroup("Fri", IMAGE_SUNNY, 71, 66) } } } }; TileContent content = new TileContent() { Visual = new TileVisual() { DisplayName = "Seattle", TileSmall = new TileBinding() { Content = smallContent }, TileMedium = new TileBinding() { Content = mediumContent, Branding = TileBranding.Name }, TileWide = new TileBinding() { Content = wideContent, Branding = TileBranding.NameAndLogo }, TileLarge = new TileBinding() { Content = largeContent, Branding = TileBranding.NameAndLogo } } }; string expectedPayload = $@"<?xml version=""1.0"" encoding=""utf-8""?><tile><visual displayName=""Seattle""><binding template=""TileSmall"" hint-overlay=""30"" hint-textStacking=""center"">{GenerateStringBackgroundImage()}<text hint-align=""center"" hint-style=""body"">Mon</text><text hint-align=""center"" hint-style=""base"">63°</text></binding><binding template=""TileMedium"" branding=""name"" hint-overlay=""30"">{GenerateStringBackgroundImage()}<group>"; // Medium tile subgroups expectedPayload += GenerateStringMediumSubgroup("Mon", IMAGE_MOSTLY_CLOUDY, 63, 42); expectedPayload += GenerateStringMediumSubgroup("Tue", IMAGE_CLOUDY, 57, 38); expectedPayload += "</group></binding>"; // Wide tile expectedPayload += @"<binding template=""TileWide"" branding=""nameAndLogo"" hint-overlay=""30"">"; expectedPayload += GenerateStringBackgroundImage(); expectedPayload += "<group>"; // Wide tile subgroups expectedPayload += GenerateStringWideSubgroup("Mon", IMAGE_MOSTLY_CLOUDY, 63, 42); expectedPayload += GenerateStringWideSubgroup("Tue", IMAGE_CLOUDY, 57, 38); expectedPayload += GenerateStringWideSubgroup("Wed", IMAGE_SUNNY, 59, 43); expectedPayload += GenerateStringWideSubgroup("Thu", IMAGE_SUNNY, 62, 42); expectedPayload += GenerateStringWideSubgroup("Fri", IMAGE_SUNNY, 71, 66); expectedPayload += "</group></binding>"; // Large tile expectedPayload += @"<binding template=""TileLarge"" branding=""nameAndLogo"" hint-overlay=""30"">"; expectedPayload += GenerateStringBackgroundImage(); expectedPayload += $@"<group><subgroup hint-weight=""30""><image src=""{IMAGE_MOSTLY_CLOUDY}"" /></subgroup><subgroup><text hint-style=""base"">Monday</text><text>63° / 42°</text><text hint-style=""captionSubtle"">20% chance of rain</text><text hint-style=""captionSubtle"">Winds 5 mph NE</text></subgroup></group>"; expectedPayload += "<text />"; expectedPayload += "<group>"; // Large tile subgroups expectedPayload += GenerateStringLargeSubgroup("Tue", IMAGE_CLOUDY, 57, 38); expectedPayload += GenerateStringLargeSubgroup("Wed", IMAGE_SUNNY, 59, 43); expectedPayload += GenerateStringLargeSubgroup("Thu", IMAGE_SUNNY, 62, 42); expectedPayload += GenerateStringLargeSubgroup("Fri", IMAGE_SUNNY, 71, 66); expectedPayload += "</group></binding></visual></tile>"; string actualPayload = content.GetContent(); AssertHelper.AssertXml(expectedPayload, actualPayload); //Assert.AreEqual(expectedPayload, actualPayload); }
private void EvaluateMessages(Messages obj) { if (obj == Messages.NotesChanged) { var vm = SimpleIoc.Default.GetInstance<MainViewModel>(); if (vm != null && vm.NoteCollections != null) { var newNotes = vm.NoteCollections.SelectMany(noteCollectionModel => noteCollectionModel.NewNotes).ToList(); var adap2 = new TileBindingContentAdaptive() { Children = { new AdaptiveText() { HintStyle = AdaptiveTextStyle.Title, Text = newNotes.Count + " pending" }, // For spacing new AdaptiveText() } }; foreach (var noteModel in newNotes) { adap2.Children.Add(new AdaptiveText() { Text = noteModel.Content, HintStyle = AdaptiveTextStyle.BodySubtle }); } var tileLarge = new TileBinding() { Branding = TileBranding.None, Content = adap2 }; var tileSmall = new TileBinding() { Branding = TileBranding.None, Content = new TileBindingContentAdaptive() { Children = { new AdaptiveText() { HintStyle = AdaptiveTextStyle.Header, Text = newNotes.Count.ToString("00"), HintAlign = AdaptiveTextAlign.Center } } } }; var tileVisual = new TileVisual() { TileLarge = tileLarge, TileMedium = tileLarge, TileWide = tileLarge, TileSmall = tileSmall, }; var tileContent = new TileContent() { Visual = tileVisual }; var notif = new TileNotification(tileContent.GetXml()); var updater = TileUpdateManager.CreateTileUpdaterForApplication(); updater.Update(notif); } } }
public async void Run(IBackgroundTaskInstance taskInstance) { BackgroundTaskDeferral _defferal = taskInstance.GetDeferral(); var appdata = ApplicationData.Current.LocalSettings; if (!(bool) (appdata.Values["TileUpdates"] ?? false) && !(bool) (appdata.Values["UseToasts"] ?? false)) // if task isn't needed, kill it { _defferal.Complete(); return; } PasswordVault vault = new PasswordVault(); PasswordCredential cred; try { cred = vault.FindAllByResource("MYUW").First(); // Make sure this matches CredResName } catch { _defferal.Complete(); return; } var connector = new MUConnector(cred); if (await connector.Login()) { //double lastValue = (float)(appdata.Values["LastValue"] ?? -1); //shit's stored as a float... avoids invalid cast float lastValue = -1; if (appdata.Values.ContainsKey("LastValue")) { float? lv = appdata.Values["LastValue"] as float?; // stupid workarounds for float precision lastValue = lv.Value; } var hfs = await connector.GetHfsData(); var term = await connector.GetTermInfo(); double average = hfs.resident_dining.balance / term.AdjustedDaysRemaining(LoadSavedDates()); if ((bool)(appdata.Values["TileUpdates"] ?? false)) { var bindingContent = new TileBindingContentAdaptive(); var medBindingContent = new TileBindingContentAdaptive(); var items = bindingContent.Children; var medItems = medBindingContent.Children; medItems.Add(new TileText() { Text = $"{hfs.resident_dining.balance:C} remaining", Style = TileTextStyle.Body }); items.Add(new TileText() { Text = $"{hfs.resident_dining.balance:C} remaining", Style = TileTextStyle.Subtitle }); var line2 = new TileText() { Text = $"{term.AdjustedDaysRemaining(LoadSavedDates())} days", Style = TileTextStyle.Caption }; var line3 = new TileText() { Text = $"${average:0.00} per day", Style = TileTextStyle.Caption }; items.Add(line2); items.Add(line3); medItems.Add(line2); medItems.Add(line3); var tileBinding = new TileBinding() { Content = bindingContent, DisplayName = "FoodTile", Branding = TileBranding.NameAndLogo }; var medTileBinding = new TileBinding() { Content = medBindingContent, DisplayName = "FoodTile", Branding = TileBranding.NameAndLogo }; var content = new TileContent() { Visual = new TileVisual { TileMedium = medTileBinding, TileWide = tileBinding, TileLarge = tileBinding } }; var note = new TileNotification(content.GetXml()); var updater = TileUpdateManager.CreateTileUpdaterForApplication(); updater.Update(note); } if (hfs.resident_dining.balance != lastValue) { if ((bool)(appdata.Values["UseToasts"] ?? false)) { var toastContent = new ToastContent() { Visual = new ToastVisual() { TitleText = new ToastText() { Text = $"Dining Balance ${hfs.resident_dining.balance:0.00}" }, BodyTextLine1 = new ToastText() { Text = $"New daily average ${average:0.00}" }, BodyTextLine2 = new ToastText() { Text = $"{term.AdjustedDaysRemaining(LoadSavedDates())} days remaining in quarter" } } }; var note = ToastNotificationManager.CreateToastNotifier(); var toast = new ToastNotification(toastContent.GetXml()); note.Show(toast); } appdata.Values["LastValue"] = hfs.resident_dining.balance; } } connector.Dispose(); _defferal.Complete(); }
private static TileBinding GetBindingWideContent(string income, string spending, string earnings) { var content = new TileBindingContentAdaptive { PeekImage = new TilePeekImage { Source = "Assets/Wide310x150Logo.png" }, Children = { new AdaptiveText { Text = income, HintStyle = AdaptiveTextStyle.CaptionSubtle }, new AdaptiveText { Text = spending, HintStyle = AdaptiveTextStyle.CaptionSubtle }, new AdaptiveText { Text = earnings, HintWrap = true, HintStyle = AdaptiveTextStyle.Body } } }; return new TileBinding { Branding = TileBranding.NameAndLogo, DisplayName = Strings.ApplicationTitle, Content = content }; }
private static void AssertBindingMediumAdaptive(string expectedBindingXml, TileBindingContentAdaptive content) { AssertBindingMedium(expectedBindingXml, new TileBinding() { Content = content }); }
public void SendEventTileNotification(EventTileModel etm) { var content = new TileBindingContentAdaptive(); TileGroup firstGroup = new TileGroup(); TileSubgroup sgroup = new TileSubgroup(); sgroup.Weight = 22; TileImage imgOrganizer = new TileImage(); var uriImageOrganizer = etm.OrganizerImageAbsoluteUri; if (string.IsNullOrEmpty(uriImageOrganizer)) uriImageOrganizer = unknownPersonImageUri.AbsoluteUri; imgOrganizer.Source = new TileImageSource(uriImageOrganizer); sgroup.Children.Add(imgOrganizer); firstGroup.Children.Add(sgroup); sgroup = new TileSubgroup(); TileText organizerName = new TileText(); organizerName.Text = etm.OrganizerName; sgroup.Children.Add(organizerName); TileText timeEvent = new TileText(); timeEvent.Text = etm.TimeDelta; timeEvent.Style = TileTextStyle.CaptionSubtle; sgroup.Children.Add(timeEvent); TileText eventBdy = new TileText(); eventBdy.Text = etm.Subject; sgroup.Children.Add(eventBdy); firstGroup.Children.Add(sgroup); content.Children.Add(firstGroup); foreach (var driveItem in etm.Items.Take(2)) { TileGroup secondGroup = new TileGroup(); sgroup = new TileSubgroup(); TileImage imgExt = new TileImage(); imgExt.Source = new TileImageSource(driveItem.IconAbsoluteUri); sgroup.Children.Add(imgExt); sgroup.Weight = 5; secondGroup.Children.Add(sgroup); sgroup = new TileSubgroup(); TileText tt = new TileText(); tt.Text = driveItem.Title; sgroup.Children.Add(tt); secondGroup.Children.Add(sgroup); content.Children.Add(secondGroup); } TileContent tileContent = new TileContent() { Visual = new TileVisual() { TileWide = new TileBinding() { Content = content }, TileMedium = new TileBinding() { Content = content }, } }; try { var tileContentxml = tileContent.ToString(); TileNotification notification = new TileNotification(tileContent.GetXml()); TileUpdateManager.CreateTileUpdaterForApplication().Update(notification); } catch (Exception ex) { throw; } }
internal async Task<bool> PinAsync(DetailPageViewModel detailPageViewModel) { var name = "Tiles sample"; var title = "Template 10"; var body = detailPageViewModel.Value; var image = "https://raw.githubusercontent.com/Windows-XAML/Template10/master/Assets/Template10.png"; var bindingContent = new TileBindingContentAdaptive() { PeekImage = new TilePeekImage() { Source = new TileImageSource(image) }, Children = { new TileText() { Text = title, Style = TileTextStyle.Body }, new TileText() { Text = body, Wrap = true, Style = TileTextStyle.CaptionSubtle } } }; var binding = new TileBinding() { Branding = TileBranding.NameAndLogo, DisplayName = name, Content = bindingContent }; var content = new TileContent() { Visual = new TileVisual() { TileMedium = binding, TileWide = binding, TileLarge = binding } }; var xml = content.GetXml(); // show tile var tileId = detailPageViewModel.ToString(); if (!await IsPinned(detailPageViewModel)) { // initial pin var logo = new Uri("ms-appx:///Assets/Logo.png"); var secondaryTile = new SecondaryTile(tileId) { Arguments = detailPageViewModel.Value, DisplayName = name, VisualElements = { Square44x44Logo = logo, Square150x150Logo = logo, Wide310x150Logo = logo, Square310x310Logo = logo, ShowNameOnSquare150x150Logo = true, }, }; if (!await secondaryTile.RequestCreateAsync()) { System.Diagnostics.Debugger.Break(); return false; } } // add notifications var tileNotification = new TileNotification(xml); var tileUpdater = TileUpdateManager.CreateTileUpdaterForSecondaryTile(tileId); tileUpdater.Update(tileNotification); // show toast ShowToast(detailPageViewModel); // result return true; }
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(); }