WPF 'Toaster' Popup - How to close?

空扰寡人 提交于 2019-12-08 09:33:09

问题


I'm using the following to create 'toaster' style pop-ups: Create popup "toaster" notifications in Windows with .NET

Unfortunately, after the message "disappears", there is still a 'task' in the taskbar. After showing multiple popups, there is a separate 'task' for each popup that was opened, all stacked on top of each other.

How can I close these after the opacity animation has completed?


回答1:


I wrote my own toast implementation, perhaps you can find use of it! It's very simple, all you do is:

ToastMessage.Show("My message", "My Title");

And you're done! :) I'll keep updating it until I think it's perfect, but modify it as you wish! I'm yet to add things like animations and sound effects.

Here is the link: GitHub WPFToastMessage




回答2:


I figured this out and it's pretty easy!

I changed this (minus space at beginning):

< Storyboard>

To this:

< Storyboard Completed="Storyboard_Completed">

Then in the 'properties' pane under events, I double-clicked the new event that was auto-added and got this:

private void Storyboard_Completed(object sender, EventArgs e)
{
}

And simply added:

    this.Close();


来源:https://stackoverflow.com/questions/19102288/wpf-toaster-popup-how-to-close

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