[英]How to minimize and restore a WPF window by clicking taskbar icon?
I would like to know if it is possible to be able to minimize and restore a window (WPF) by clicking on the icon in the taskbar with the window style "none".我想知道是否可以通过单击任务栏中窗口样式为“无”的图标来最小化和恢复窗口(WPF)。
Thank you谢谢
You can use the double_click event and check for the form state, then minimaze or restore it as needed.您可以使用 double_click 事件并检查表单状态,然后根据需要将其最小化或恢复。 You need of course a taskbarIcon controler.你当然需要一个 taskbarIcon 控制器。
example:例子:
private bool _isShowed = false;
private void Form1_Load(object sender, EventArgs e)
{
_isShowed = true;
}
// handle double click on icon
private void OnDoubleClickHandler(object sender, EventArgs e)
{
if (_isShowed)
{
_isShowed = false;
Hide();
}
else
{
_isShowed = true;
Show();
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.