在已部署的应用程序上运行时更改任务栏图标 [英] Change taskbar icon at runtime on deployed app

查看:38
本文介绍了在已部署的应用程序上运行时更改任务栏图标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想更改任务栏图标以在收到新邮件时通知用户,例如当您收到新邮件时使用 Outlook.

I would like to change taskbar icon to notify the user when a new message is received like outlook when you receive a new mail.

我已经在网上搜索了解决方案,这就是像这样更改窗口图标:

I already search solution on web and it's all about changing the window icon like this:

Uri iconUri = new Uri("Resources/envelop.ico", UriKind.Relative);
this.Icon = BitmapFrame.Create(iconUri);

它在 Visual Studio 上运行良好,但我发现它并没有改变我在已部署应用程序上的任务栏,因为它是一个只读变量.更糟糕的是,它只更改了我不想更改的左上角附加图标.

It's working well on Visual Studio but I found out that it's not changing my task bar on deployed app because it's a read-only variable. And worse it's change only the top-left attached icon that I didn't want to change anyways.

那么有办法吗?Outlook 做到了,Chrome 也做到了,所以一定有办法.

So is there a way to do it? Outlook did it and Chrome too so there must be a way.

更新

为了在我部署的应用程序上强制刷新图标,我必须固定/取消固定我的图标任务栏,不幸的是,这只是一个用户命令,所以我无法在 wpf 中以编程方式执行此操作,而无需利用一些太不稳定的肮脏方式.

To force the icon refresh on my deployed app I have to pin/unpin my icon taskbar, unfortunately this is a user command only so I can't do this in wpf programmatically without exploiting some dirty manners which would be too unstable.

实际上,我正在尝试找到一种刷新图标缓存的方法,而无需针对每个 Windows 操作系统或版本执行此操作.

Actually I'm trying to find a way to refresh Icon cache without doing it for each Windows OS or version.

推荐答案

需要考虑的两个步骤:

  1. 您需要注意您的软件是否也安装在控制面板中.如果是,请尝试从那里卸载它,但将软件的运行时文件夹保存在某个地方以供测试.

  1. You need to pay attention if your software is also installed in Control Panel. If it does, then try to uninstall it from there but keep your runtime folder of your software somewhere to keep them for a test.

从 %AppData% 中删除您的软件数据文件并尝试再次运行软件而不安装它(您复制运行时文件夹的位置),您应该能够看到任务栏如何刷新它.

Delete from %AppData% your software data files and try to run software again without installing it (Where you copied your runtime folder) and you should be able to see how Taskbar is refreshing it.

您需要弄清楚的一件事是,为什么在控制面板中安装软件会出现这样的故障,以至于它不会刷新任务栏中的图标.

One thing you need to sort out is why having software installed in Control panel makes such glitch that it doesn't refresh your icon in taskbar.

这篇关于在已部署的应用程序上运行时更改任务栏图标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆