Windows notification created with NotifyIcon shows “microsoft.explorer.notification” and GUID

落花浮王杯 提交于 2020-06-12 05:50:30

问题


We have written a WPF desktop application for Windows. The application launches on start-up and mostly runs in the background, but has a UI which is accessible via the system tray. Occasionally the app needs to notify the user of something, and so for this, we use the NotifyIcon library to generate notifications. Here is the relevant code:

XAML:

<mui:ModernWindow
    ...
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:tb="http://www.hardcodet.net/taskbar" 
    ... >

    <tb:TaskbarIcon
            x:Name="MyAppIcon"
            ...
    </tb:TaskbarIcon>
</mui:ModernWindow>

C# code behind:

using Hardcodet.Wpf.TaskbarNotification

public void ShowStartupBalloon(string message)
{
    // show balloon with built-in icon ie 'Info'
    MyAppIcon.ShowBalloonTip(Properties.Resources.App_Title, message, BalloonIcon.Info);
}

The notifications appear as small floating windows near the taskbar, but (sometimes, not always) they include the string "microsoft.explorer.notification" and GUID.

We would like to eliminate these as they are confusing our customers; many think some kind of error in the software has occurred. Does anyone know how to suppress that in order to display only the text of the notification we have supplied?


回答1:


I've experienced this problem as well. From what I've gathered, that bottom text is Microsoft's way of making sure that a user knows the source of a notification, and that random programs can't impersonate a genuine windows notification. The inclusion of a ToolTipIcon (in your case the info icon) seems to trigger this.

As a result, you can remove that text completely by not specifying a BalloonTipIcon, either by not defining the property at all, or defining it as None:

MyAppIcon.ShowBalloonTip(Properties.Resources.App_Title, message, BalloonIcon.None);

The only tradeoff, of course, is that your notification won't have an icon.

Hope this helps.




回答2:


Show icon with automatic timeout:

public static void ShowBalloon(string title, string body)
{
    // Show with icon
    NotifyIcon ni = new NotifyIcon() { Visible = true, Icon = Properties.Resources.Icon};

    // Timeout is deprecated since Vista
    ni.ShowBalloonTip(0, title, body, ToolTipIcon.None);

    // Dispose on event
    ni.BalloonTipClosed += (sender, e) => ni.Dispose();
}


来源:https://stackoverflow.com/questions/55766617/windows-notification-created-with-notifyicon-shows-microsoft-explorer-notificat

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!