UWP 应用通知Notifications

简介: 原文:UWP 应用通知Notifications之前说UWP 使用OneDrive云存储2.x api(二)【全网首发】,微识别实现了上传下载的功能,那么为了给用户更上一层楼的体验,那就是在上传下载完成之后,弹出一通知Notifications。
原文: UWP 应用通知Notifications

之前说UWP 使用OneDrive云存储2.x api(二)【全网首发】,微识别实现了上传下载的功能,那么为了给用户更上一层楼的体验,那就是在上传下载完成之后,弹出一通知Notifications。

关于Notifications,在UWP Community Toolkit中也有简单介绍,不过微软还除了一个更为强大的,

专门介绍 Tiles 和 Notifications 的工具————Notifications Visualizer

商店搜索即可下载,这个貌似没有源代码。不过也不需要了。因为里面各种样式都可以直接导出代码,供你直接拿来用。

 

 

 

 

 很炫酷吧,不过我这里只是介绍一下这个工具,并结合我的实际例子来说明

 

 这是我的在上传完成后的通知,封装好了,放进去直接调用。

我只加了一个 AdaptiveText(),可以加多个的。并且 ToastButton参数设置None了,就是点击 后消除通知。

 

private void PopupToast(string strMainContent, string strButtonContent)
        {
            var toastContent = new ToastContent()
            {
                Visual = new ToastVisual()
                {
                    BindingGeneric = new ToastBindingGeneric()
                    {
                        Children =
                            {
                                new AdaptiveText()
                                {
                                    Text = strMainContent
                                },
                            },
                        //AppLogoOverride = new ToastGenericAppLogo()
                        //{
                        //    Source = "https://unsplash.it/64?image=1005",
                        //    HintCrop = ToastGenericAppLogoCrop.Circle
                        //}
                    }
                },
                Actions = new ToastActionsCustom()
                {
                    Buttons =
                        {
                            new ToastButton(strButtonContent, "None")
                            {
                                ActivationType = ToastActivationType.Foreground
                            }
                        }
                }
            };

            // Create the toast notification
            var toastNotif = new ToastNotification(toastContent.GetXml());

            // And send the notification
            ToastNotificationManager.CreateToastNotifier().Show(toastNotif);
        }

 

 

 

 不错吧,姿势有很多。总有一个满足你

 

目录
相关文章
|
API Android开发
Notification(状态栏通知)详解
Android中用于在状态栏显示通知信息的控件:Notification,相信大部分学Android都对他都很熟悉,而网上很多关于Notification的使用教程都是基于2.x的,而现在普遍的Android设备基本都在4.x以上,甚至是5.0以上的都有;他们各自的Notification都是不一样的!而本节给大家讲解的是基于4.x以上的Notification。
174 0
|
数据可视化 C# 开发工具
C#或Winform中的消息通知之系统本地通知(local toast notification)
C#应用通过 Microsoft.Toolkit.Uwp.Notifications NuGet包可以很方便的发送本地通知,适用于所有类型的应用(WPF、UWP、WinForms、控制台)
757 0
C#或Winform中的消息通知之系统本地通知(local toast notification)
|
Web App开发
Chrome浏览器使用Notification通知消息推送
Chrome浏览器使用Notification通知消息推送
1184 0
Chrome浏览器使用Notification通知消息推送
如何启用SAP C4C OData Event Notification
如何启用SAP C4C OData Event Notification
111 0
|
设计模式 前端开发
使用 MVVMLight 消息通知
原文:使用 MVVMLight 消息通知 欢迎阅读我的MVVMLight教程系列文章《关于 MVVMLight 设计模式系列》 在文章的其实我们就说了,MVVMLight的精华就是消息通知机制,设计的非常不错。
1055 0
|
调度 iOS开发
iOS Notification(本地通知)
代码 #import "ViewController.h" @interface ViewController () @end @implementation ViewController - (void)viewDidLoad { ...
929 0