我有一个在Windows 10上运行的桌面应用程序,它创建ToastNotifications并存储在Action Center中。我注意到,当我重新启动计算机时,通知仍然存在于Action Center中,因此当它们不再需要时,我希望通过我的应用程序将它们移除。
我想使用ToastNotificationHistory的Remove
方法来实现这个功能。
我的代码如下:
public static void RemoveNotificationByTag(string toastTag)
{
ToastNotificationManager.History.Remove(toastTag, "TEST");
}
但这会导致以下异常:
System.Exception: '未找到元素。 (来自 HRESULT 的异常:0x80070490)'
之前发送的通知具有Tag
和Group
值。调用
RemoveGroup
或GetHistory
方法时也会出现相同的异常。基本上似乎我无法调用History类中的任何方法而不会得到相同的异常。
Clear()
呢?“从操作中心中移除此应用发送的所有通知。” - stuartd