首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用桌面应用程序的Windows 10上的通知

问使用桌面应用程序的Windows 10上的通知
EN

Stack Overflow用户
提问于 2014-10-04 19:24:56
回答 3查看 11.8K关注 0票数 7

我在C#中得到了一个带有NotifyIcon的Windows Forms项目。我使用以下代码来显示气球通知:

代码语言:javascript
复制
notifyIcon.ShowBalloonTip(1000, "title", "text", ToolTipIcon.Info);

在Windows8.1之前,它一直运行得很好。现在我已经安装了Windows10预览版,气球通知不再出现。

我猜所有的通知都被移到了Windows8风格的toast通知,气球通知也被完全删除了(因为我还没有看到一个气球通知和更多的toast通知),但是我还没有找到这个的官方来源。

问题是我的应用程序只是一个.exe文件,所以它没有安装程序或快捷方式。根据this页面的说法,需要一个创建快捷方式的安装程序才能使toast通知工作。

在没有任何快捷方式或安装程序的情况下,如何在Windows10中显示通知(我不在乎它是气球通知还是吐司通知)?

EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2014-11-19 15:39:05

嗯,在技术预览版(在系统托盘旁边有一个通知中心)的最后一次更新之后,它可以工作了。

我的通知像往常一样显示,没有任何代码更改。它们就像普通的Windows8风格的吐司通知,除了这些显示在底部。

票数 0
EN

Stack Overflow用户

发布于 2017-04-28 02:40:01

我使用这个线程来帮助制作这段代码--我正在分享我的成功。

警告:我对C#比较陌生,所以我的代码可能很糟糕,但它确实可以工作,而且非常简单,这比我找到的大多数解决方案都要好

另外,我花了一段时间来读取xml文档。我在和System.xml (我想)和Windows.Data.Dom.Xml (也不是完全确定)战斗。最后,我决定将它们作为我的示例文件的硬编码字符串,并使用switch语句在它们之间进行切换。我在堆栈溢出上发现了很多人,他们正在寻找我想出的解决方案。似乎在控制台或后台应用程序中使用toast通知系统将非常有用,并且围绕windows应用程序的toast通知系统的文档都表明它需要与应用程序一起使用。Action Center对于NotificationTray/NotifyIcon路由的通知非常有用。我还没有在网上找到一个完整的解决方案。以下是示例代码。

代码语言:javascript
复制
/*
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);


        }
    }
}
票数 1
EN

Stack Overflow用户

发布于 2015-11-27 14:05:46

这个解决方案对我很有效:

设置为"Enabled"

  • Restart

的任务栏配置和管理模板的开始菜单和任务栏禁用将气球通知显示为吐司

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/26192333

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档