问题
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