code:
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using System.Data;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Notifications;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;
using Windows.Data.Xml.Dom;
// The Blank Page item template is documented at https://go.microsoft.com/fwlink/?LinkId=402352&clcid=0x409
namespace App3
{
/// <summary>
/// An empty page that can be used on its own or navigated to within a Frame.
/// </summary>
public sealed partial class MainPage : Page
{
public MainPage()
{
this.InitializeComponent();
}
private void ShowToast()
{
string title = "featured picture of the day";
string content = "beautiful scenery";
string image = "https://preview.qiantucdn.com/original_origin_pic/19/03/05/ad08d2302706e9f8d8b64b5ab0c3b23b.png!qt324new_nowater_webp";
string logo = "https://preview.qiantucdn.com/original_origin_pic/19/03/05/e2c60d1317f3019ce20919b0ec568082.png!qt324new_nowater_webp";
string xmlString =
$@"<toast><visual>
<binding template='ToastGeneric'>
<text>{title}</text>
<text>{content}</text>
<image src='{image}'/>
<image src='{logo}' placement='appLogoOverride' hint-crop='circle'/>
</binding>
</visual></toast>";
XmlDocument toastXml = new XmlDocument();
toastXml.LoadXml(xmlString);
ToastNotification toast = new ToastNotification(toastXml);
ToastNotificationManager.CreateToastNotifier().Show(toast);
}
private void Button_Click(object sender, RoutedEventArgs e)
{
ShowToast();
}
}
}
其他APP 好像也可以调用这种系统特性(需要引入必要的引用):
https://docs.microsoft.com/en-us/windows/apps/desktop/modernize/desktop-to-uwp-enhance