简体   繁体   English

WPF“烤面包机”弹出窗口-如何关闭?

[英]WPF 'Toaster' Popup - How to close?

I'm using the following to create 'toaster' style pop-ups: Create popup "toaster" notifications in Windows with .NET 我正在使用以下内容来创建“烤面包机”样式的弹出窗口: 在Windows中使用.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? 不透明度动画完成后如何关闭它们?

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 这里是链接: GitHub WPFToastMessage

I figured this out and it's pretty easy! 我想通了,这很容易!

I changed this (minus space at beginning): 我改变了这一点(开始时减去空格):

< Storyboard> <故事板>

To this: 对此:

< Storyboard Completed="Storyboard_Completed"> <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();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM