wpf 如何在 Windows 通知栏中显示弹出通知
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13728969/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to show popup notifications in windows notification bars
提问by John Demetriou
I am creating my personal gmail checker in C# and I need a way to popup a notification in system tray whenever there is a new email and how to control the contents of that notification bar. Also if possible I don't need it to be like windows notifications but my personal way. For example not popup like a notification but like a rectangle (or square or whatever) and if windows taskbar is in autohide the taskbar not be shown but only the notification. Also it is a wpf app. If you need more info let me know
我正在用 C# 创建我的个人 gmail 检查器,我需要一种方法来在有新电子邮件时在系统托盘中弹出通知以及如何控制该通知栏的内容。另外,如果可能的话,我不需要它像 Windows 通知那样,而是我个人的方式。例如,不是像通知那样弹出,而是像矩形(或正方形或其他)那样弹出,如果 Windows 任务栏处于自动隐藏状态,则不会显示任务栏而只显示通知。它也是一个 wpf 应用程序。如果您需要更多信息,请告诉我
回答by Jared Harley
Sounds like you're looking at trying to create a "toaster"-style popup. You can take a look at including something like this WPF NotifyIcon:
听起来您正在尝试创建一个“烤面包机”风格的弹出窗口。您可以查看包含类似WPF NotifyIcon 的内容:
This is an implementation of a NotifyIcon (aka system tray icon or taskbar icon) for the WPF platform. It does not just rely on the Windows Forms NotifyIcon component, but is a purely independent control which leverages several features of the WPF framework in order to display rich ToolTips, Popups, context menus, and balloon messages. It can be used directly in code or embedded in any XAML file.
这是 WPF 平台的 NotifyIcon(又名系统托盘图标或任务栏图标)的实现。它不仅依赖于 Windows 窗体 NotifyIcon 组件,而且还是一个纯粹的独立控件,它利用了 WPF 框架的多个功能来显示丰富的工具提示、弹出窗口、上下文菜单和气球消息。它可以直接在代码中使用或嵌入到任何 XAML 文件中。
You could also look at using a notification framework like Growl for Windows:
您还可以考虑使用像Growl for Windows这样的通知框架:
Ok, so what is Growl?
Put simply, Growl lets you know when things happen. Files finished downloading, friends came online, new email has arrived - Growl can let you know when any event occurs with a subtle notification. The rest of the time, Growl stays out of your way.
Along with letting you know when things happen, Growl also gives you full control over how you are notified and what action (if any) you want to take in response to the notification. You can choose to be alerted with a visual indicator or an audible alert, both, or neither. You can choose the type of display that is shown, whether the display remains on the screen, the importance of the notification, and even if the notification should be forwarded to another computer. You can have notifications that trigger an email, run a script, launch a program, or are read out loud.
好的,那么什么是咆哮?
简而言之,Growl 让您知道事情何时发生。文件下载完毕,朋友上线,新电子邮件已到达 - Growl 可以在发生任何事件时通过微妙的通知让您知道。其余时间,Growl 不会挡路。
除了让您知道事情发生时,Growl 还让您完全控制您收到通知的方式以及您想对通知采取什么行动(如果有)。您可以选择使用视觉指示器或声音警报,或者两者都没有。您可以选择显示的显示类型、显示是否保留在屏幕上、通知的重要性,以及是否应将通知转发到另一台计算机。您可以使用触发电子邮件、运行脚本、启动程序或大声朗读的通知。
You can find the documentation and Growl.net files on Growl's developer page.
您可以在Growl 的开发人员页面上找到文档和 Growl.net 文件。


