1. 程式人生 > >UWP 應用通知Notifications

UWP 應用通知Notifications

AI 上傳 介紹 comm src ner rop 雲存儲 app

原文: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); }

不錯吧,姿勢有很多。總有一個滿足你技術分享圖片

UWP 應用通知Notifications