我想在this example的windows 10中創建簡單的Toast通知到動作中心。但我在步驟2上遇到問題:Windows.UI.Notifications缺失
using Windows.UI.Notifications;
它缺少。但是我花了很多時間找到它並沒有得到任何結果。我真的不知道我在哪裏可以找到或至少下載它。
我試了一下:
- 漫長的探索後,我發現
Windows.UI.dll
在C:\Windows\System32
但是當我嘗試將其添加爲引用到項目中,我得到這個錯誤。即使在我試圖複製它,做出這個完全訪問沒有任何改變
- 我試過。NET(我真的使用4.5.2),重新安裝
- 安裝了Windows 10 SDK
- 試圖與全球
- 新增
- 新增
System.Runtime.dll
參考
導入<PropertyGroup> <TargetPlatformVersion>10.0</TargetPlatformVersion> </PropertyGroup>
示例代碼這可能是你沒用:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Toolkit.Uwp.Notifications;
using Microsoft.QueryStringDotNET;
using Windows.UI.Notifications;
namespace MessagerClient.Notifications {
class DefaultWindowsNotification {
public static void notificationTest() {
string title = "Andrew sent you a picture";
string content = "Check this out, Happy Canyon in Utah!";
string image = "http://blogs.msdn.com/something.jpg";
string logo = "ms-appdata:///local/Andrew.jpg";
ToastVisual visual = new ToastVisual() {
BindingGeneric = new ToastBindingGeneric() {
Children =
{
new AdaptiveText()
{
Text = title
},
new AdaptiveText()
{
Text = content
},
new AdaptiveImage()
{
Source = image
}
},
AppLogoOverride = new ToastGenericAppLogo() {
Source = logo,
HintCrop = ToastGenericAppLogoCrop.Circle
}
}
};
Console.WriteLine("NOTIFICATION");
//Can`t use because of Windows.UI library
ToastNotificationManager.CreateToastNotifier().Show(visual);
}
}
}
也許[這篇文章](http://stackoverflow.com/questions/16486460/showing-windows-8-toast-from-windows-forms-app)可以幫助你。 –
[請閱讀**本文**以瞭解如何在桌面應用中使用UWP通知。](https://docs.microsoft.com/en-us/windows/uwp/porting/desktop-to-uwp-enhance) – Mike