zoukankan      html  css  js  c++  java
  • UWP 系统通知测试

    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

  • 相关阅读:
    python常用模块②
    python常用模块①
    面向对象相关部分双下划线方法补充
    面向对象进阶 上
    面向对象初识④
    面向对象初识③
    综合架构-负载均衡
    wecent 搭建
    综合架构--存储
    综合架构--备份
  • 原文地址:https://www.cnblogs.com/wgscd/p/12971010.html
Copyright © 2011-2022 走看看