C# Windows 10上使用桌面应用程序的通知
我得到了一个C语言的Windows窗体项目,其中有一个notify图标。我正在使用以下代码显示气球通知:C# Windows 10上使用桌面应用程序的通知,c#,windows,winforms,notifications,C#,Windows,Winforms,Notifications,我得到了一个C语言的Windows窗体项目,其中有一个notify图标。我正在使用以下代码显示气球通知: notifyIcon.ShowBalloonTip(1000, "title", "text", ToolTipIcon.Info); 在Windows 8.1之前,它一直运行良好。现在我已经安装了Windows10预览版,气球通知不再显示 我猜所有通知都被移动到Windows8风格的toast通知,气球通知被完全删除,因为我还没有看到一个气球通知和更多的toast通知,但是我还没有找到这
notifyIcon.ShowBalloonTip(1000, "title", "text", ToolTipIcon.Info);
在Windows 8.1之前,它一直运行良好。现在我已经安装了Windows10预览版,气球通知不再显示
我猜所有通知都被移动到Windows8风格的toast通知,气球通知被完全删除,因为我还没有看到一个气球通知和更多的toast通知,但是我还没有找到这方面的官方来源
问题是我的应用程序只是一个.exe文件,因此没有安装程序或快捷方式。根据page,toast通知需要一个创建快捷方式的安装程序才能工作
如何显示通知我不在乎在Windows 10中它是气球还是土司通知,没有任何快捷方式或安装程序?在上次更新技术预览后,在系统托盘旁边有一个通知中心,它正在工作
我的通知像往常一样显示,没有任何代码更改。它们与普通的Windows 8风格的toast通知类似,只是它们显示在底部。这个解决方案对我很有效: 打开gpedit.msc 用户配置->管理模板->开始菜单和任务栏->禁用将气球通知显示为已启用的祝酒词 重新启动Windows
我用这个帖子来帮助编写这个代码——我正在分享我的成功 警告:我对C有点陌生,所以我的代码可能很糟糕——但它确实可以工作,而且非常简单,对于我找到的大多数解决方案来说,这超出了我所能说的范围 另外,我在阅读xml文档时也经历了一段痛苦的时光。我想我是在与System.xml作斗争,而Windows.Data.Dom.xml也不完全确定。 最后,我决定为我的示例文件制作硬编码字符串,并使用switch语句在它们之间切换。 我已经找到了很多人,寻找我提出的解决方案,关于堆栈溢出。将toast通知系统与控制台或后台应用程序结合使用似乎非常有用,而围绕toast通知系统与windows应用程序的文档都表明它需要与应用程序结合使用。操作中心对于通知托盘/通知图标路由的通知非常有用。我还没有在网上其他地方找到完整的解决方案。下面是示例代码
/*
At first you need to declare that your program will be using winRT libraries:
1. Right click on your yourProject, select Unload Project
2. Right click on your youProject(unavailable) and click Edit yourProject.csproj
3. Add a new property group:<TargetPlatformVersion>8.0</TargetPlatformVersion>
4. Reload project
5. Add referece Windows from Windows > Core
*/
using System;
using Windows.Data.Xml.Dom;
using Windows.Storage;
using Windows.Storage.Streams;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Windows.UI.Notifications;
namespace ConsoleApplication6
{
public class NewToastNotification
{
public NewToastNotification(string input, int type)
{
string NotificationTextThing = input;
string Toast = "";
switch (type)
{
case 1:
{
//Basic Toast
Toast = "<toast><visual><binding template=\"ToastImageAndText01\"><text id = \"1\" >";
Toast += NotificationTextThing;
Toast += "</text></binding></visual></toast>";
break;
}
default:
{
Toast = "<toast><visual><binding template=\"ToastImageAndText01\"><text id = \"1\" >";
Toast += "Default Text String";
Toast += "</text></binding></visual></toast>";
break;
}
}
XmlDocument tileXml = new XmlDocument();
tileXml.LoadXml(Toast);
var toast = new ToastNotification(tileXml);
ToastNotificationManager.CreateToastNotifier("New Toast Thing").Show(toast);
}
}
class Program
{
static void Main(string[] args)
{
NewToastNotification Window = new NewToastNotification("Yes",1);
}
}
}
许多应用程序似乎只是使用toast通知,而没有任何代码更新,但我想这是因为它们是使用安装程序安装的,并且具有快捷方式。我认为微软的开发人员在将气球通知重定向到toast通知时忘记了他们自己关于toast通知的规则。或者他们是故意的。我希望它很快会得到解决,或者至少会得到一些关于这个问题的信息。我已经写了一篇关于从桌面应用程序使用WinRT api的博客文章,例如显示Toast通知:。基本思想是在csproj中添加8.0,并添加对Windows的引用。然后,您可以使用WinRT api,例如ToastNotificationManager.CreateTastNotifier.Usablefornon-Win10应用程序!在win8+中工作,我相信是在win8+中实现了Tile