• 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

  • 相关阅读:
    Excel导出工具
    载入Properties文件中的配置项信息
    对list进行排序-重写排序规则
    Mysql 5.7版本报错 1055
    SVN客户端与服务端安装详解
    持续集成的理解
    js 日期格式化
    mysql多个时间戳字段默认值问题
    eclipse svn插件地址
    orientationchange移动端横竖屏切换属性
  • 原文地址:https://www.cnblogs.com/wgscd/p/12971010.html
Copyright © 2020-2023  润新知