- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我正在尝试使用我的WPF C# 桌面应用程序显示 Windows 10 Toasts。
遗憾的是,在非 UWP 或应用商店应用程序中,有关 Windows 10 通知的 API 和一般支持似乎非常有限且困惑。最近 UWP Community Toolkit已出版,这似乎试图让我们的事情变得更容易。还有这个商店应用程序,Notifications Visualizer ,这有助于制作这样的 toast :
我继续尝试使用 C# 和 UWP Community Toolkit 提供的 API 生成 Toast。
using Microsoft.Toolkit.Uwp.Notifications;
ToastContent toastContent = new ToastContent()
{
Visual = new ToastVisual()
{
BindingGeneric = new ToastBindingGeneric()
{
Children =
{
new AdaptiveText()
{
Text = "Matt sent you a friend request"
},
new AdaptiveText()
{
Text = "Hey, wanna dress up as wizards and ride around on our hoverboards together?"
}
},
AppLogoOverride = new ToastGenericAppLogo()
{
Source = "https://unsplash.it/64?image=1005",
HintCrop = ToastGenericAppLogoCrop.Circle
}
}
}
};
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.LoadXml(toastContent.GetContent());
var toast = new ToastNotification(xmlDoc);
ToastNotificationManager.CreateToastNotifier(AppId).Show(toast); // Display toast
不幸的是,无论我尝试什么,我似乎都无法得到相同的结果,由于某种原因图像总是丢失:
我发现的有关这些通知的大部分信息要么已过时,要么毫无用处。有人可以对此有所了解吗?谢谢。
最佳答案
看起来使用 .NET Standard 这只能通过两个步骤实现,其中之一超出了 UWP 工具包的范围。
.NET 标准应用程序需要 COM 服务器和特殊开始菜单快捷方式才能正确使用 Windows 10 操作中心。UWP Apps 似乎不需要或已经具备等效功能。 这两个步骤应该在应用程序安装期间执行,而这显然是 Microsoft UWP Toolkit 没有参与的事情。因此,仅靠 UWP 工具包不仅不能而且永远无法提供完整的解决方案,以自包含的方式显示适用于 .NET Standard 的 Windows 10 Toast。
我发现了一个不起眼的 C# Project on Github名称中包含“Microsoft”,无需 UWP 工具包即可开箱即用。它要求您提供一个 GUID 和一个 AppID 字符串,然后用于注册 COM 服务器和创建快捷方式。
一个看起来更干净的替代品是 this library这似乎提供了相同的功能。我还得测试一下。
这两种解决方案都应该适用于 Microsoft 的 NotificationsExtensions库,它是 UWP 工具包的前身,有助于生成构成 Toast 的 XML 代码。
关于c# - WPF 桌面应用程序,Windows 10 Notification Toast 2016(UWP 社区工具包),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39744331/
uwp 和非 uwp 应用程序之间是否可以进行通信。我的非uwp是一个提供服务的后台任务。我想在 uwp 应用程序中调用该非 uwp 服务。 如何调用电话? AppServiceConnection
我正在开发一个应用程序,该应用程序旨在在具有多个显示器(从 1 到 3必要)在每个监视器上,每个监视器都显示不同的 View 。 就我所见,UWP 并不自然适用于这种情况。我设法使用 CoreAppl
我正在尝试对UWP应用使用broadFileSystemAccess功能,但是package.appxmanifest的功能列表中未列出broadFileSystemAccess功能。 我的最低和最高
有时我有一个打开的流或一个事件的队列,必须在应用程序关闭时正确处理。在 WPF 应用程序中,我可以在应用程序上使用 Unloading 事件,但在 UWP 中我注意到这样的事件不存在。 我如何可靠地做
http://wikisend.com/download/880354/UWP_Server.zip 我已将代码上传至上述网址。 它是 UWP 中的客户端和服务器应用程序。这里客户端和服务器都在同一个
大家好 我知道这个问题(Chromium working on UWP)之前(2015/2016)有人问过,想看看有没有更新 我正在尝试在 UWP 应用程序中使用 CEF3 构建,但在运行该应用程序时
我目前正在构建一个应用程序,它可以使用 Windows 游戏 DVR 在某个时刻开始录制屏幕。该录音机在完成录音时将应用程序名称作为文件名。 我发现了如何使用 Applicationview.GetF
我已使用 Desktop App Converter 将我的 WPF 应用程序转换为 appx 包。我需要在资源管理器上下文菜单中有一个项目。 IE。用户右键单击文件并在主菜单中看到我的项目“对应用程
我想稍微修改一个 Button 控件(添加描述)。在哪里可以找到 UWP 控件的默认控件模板? 最佳答案 似乎可以在以下位置找到它们: C:\Program Files (x86)\Windows K
我想通过 UWP 应用访问 windows10 注册表项。 键为:\HKEY_LOCAL_MACHINE\SOFTWARE\MyCompanyName\MyName 我找不到任何函数调用来完成它。 请
我开发了一个 UWP appx,它可以安装在 cmd.exe 提示符中: C:\test>myapp.appx 但是在安装过程中会弹出一个 Windows GUI。 有没有什么方法 使用 Silent
在我的 UWP 应用程序中,如何通过 UpdateTask 中的代码进行调试? VS 2017 中的“生命周期事件”下拉菜单似乎没有提供触发此类后台任务的选项。有办法实现吗? 最佳答案 首先是关于 U
我尝试在 VS 2017 中创建一个 UWP 应用程序包。 创建时我收到一条神秘的错误消息:严重性代码描述项目文件行抑制状态错误 0xdef00532 - 资源“Files/Assets/Square
我有一个 TextBlock在我的应用程序中。我要办理pinch in & out在它上面调整字体的大小。当ManipulationDelta事件触发我检查Scale属性(property),但大多数
为什么默认选择的索引不起作用?它因平台异常而崩溃: RumTime 错误: Exception thrown at 0x00007FFDEF7F7788 (KernelBase.dll) in ab
有没有办法在同一个包中的 UWP 应用程序和桌面桥应用程序之间共享互斥锁?它们似乎有不同的命名空间;使用相同的名称不会在进程之间产生相同的对象。根据 WinObj,UWP 应用程序的对象是,存储在 A
有什么方法可以检测当前的 UWP 要退出 ? (由用户关闭或终止进程) 我想向服务器发送一些关于应用程序将断开连接的请求,还想在退出之前保存一些数据。 最佳答案 无法检测这种情况或阻止用户终止您的应用
我正在使用 XAML 和 C# 开发通用 Windows 平台应用程序。我想在 UWP 中更改焦点上 TextBox 的边框颜色。 在此先感谢您的帮助。 最佳答案 其实实现起来很简单,按照以下步骤即可
是否可以在 UWP 应用中更改甚至隐藏鼠标指针? 我唯一能找到的是: Windows.UI.Xaml.Window.Current.CoreWindow.PointerCursor = null; 但
我是一名优秀的程序员,十分优秀!