首页 > 解决方案 > 如何向 WPF 应用程序图标添加通知徽章,以便它出现在应用程序图标出现的所有位置,而不仅仅是窗口标题栏?

问题描述

我有一个带有图标的 WPF 应用程序AutoPBW.ico。现在,如果我在 MainWindow.xaml.cs 中使用此代码:

if (hosting && playerReady)
    Icon = new BitmapImage(new Uri("AutoPBW-hosting-playerReady.ico", UriKind.Relative));
else if (hosting)
    Icon = new BitmapImage(new Uri("AutoPBW-hosting.ico", UriKind.Relative));
else if (playerReady)
    Icon = new BitmapImage(new Uri("AutoPBW-playerReady.ico", UriKind.Relative));
else
    Icon = new BitmapImage(new Uri("AutoPBW.ico", UriKind.Relative));

通过将图标替换为三个备用图标之一或原始图标,我可以使两个徽章之一出现,或两者都出现,或不显示。

我的问题是:如果我这样做,图标只会在我的窗口标题栏中发生变化;它不会在任务栏或通知托盘中更改(使用 Hardcodet.Wpf.TaskbarNotification 库使通知托盘图标出现)。如何在所有位置更改我的应用程序的图标,而不仅仅是在窗口的标题栏中?

标签: c#wpf

解决方案


推荐阅读