/// <summary> /// Create a Windows Toast Notification for the given feed item /// </summary> /// <param name="feedItem"></param> public static void Toast(FeedItem feedItem) { XmlDocument toastXml = ToastNotificationManager.GetTemplateContent(ToastTemplateType.ToastImageAndText04); // Fill in the text elements XmlNodeList stringElements = toastXml.GetElementsByTagName("text"); stringElements[0].AppendChild(toastXml.CreateTextNode(feedItem.Title)); stringElements[1].AppendChild(toastXml.CreateTextNode(feedItem.FeedTitle)); stringElements[2].AppendChild(toastXml.CreateTextNode(feedItem.Summary)); // Specify the absolute path to an image string imagePath = "file:///" + Assets.RssImagePath; XmlNodeList imageElements = toastXml.GetElementsByTagName("image"); imageElements[0].Attributes.GetNamedItem("src").NodeValue = imagePath; // Open the link to the rss item if the toast notification is clicked ToastNotification toast = new ToastNotification(toastXml); toast.Activated += delegate { feedItem.OpenLink(); }; // Show the toast notification ToastNotificationManager.CreateToastNotifier(ApplicationId).Show(toast); }
/// <summary> /// Action handler for clicking an item in the feed. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void FeedItemClicked(object sender, System.Windows.Input.MouseButtonEventArgs e) { FrameworkElement control = sender as FrameworkElement; FeedItem item = control.DataContext as FeedItem; if (item != null) { item.OpenLink(); } else { logger.Warn("Unable to determine the item clicked."); } }