【发布时间】:2021-04-14 07:33:37
【问题描述】:
我一直在尝试实现一种方法来阻止用户在 Powershell 中手动单击我的 WPF 表单上的红色“x”。在线研究表明,最好的方法是使用表单关闭事件,停止事件并隐藏表单。在 C# 中似乎有很多这样做的方法,但我似乎无法为 Powershell 找到任何方法。例如,这样的东西可以在 C# 中使用。
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
e.Cancel = true;
this.Visibility = Visibility.Hidden;
}
我可以在 Powershell 中使用任何等效的东西吗?
Powershell 中关闭表单的事件是add_Closing,但我不知道如何停止关闭表单。
【问题讨论】:
标签: wpf forms powershell