我想,当用户通过单击关闭按钮(红色的X按钮)确定窗口关闭发送方在WPF窗口
而不是当的形式,因为关闭取消我的对话框中执行特定动作一些其他操作。我如何确定是否
private void Window_Closing(object sender, CancelEventArgs e)
事件是由按钮引发的?
<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Height="60" Width="284" WindowStartupLocation="CenterScreen"
BorderBrush="#FFCCCCCC"
BorderThickness="2"
Background="#FFE0E0E0"
WindowStyle="SingleBorderWindow"
ShowInTaskbar="False" ResizeMode="NoResize" Closing="Window_Closing">
只要有人关闭窗口,Window_Closing就会被触发。通过交叉按钮或通过this.close()。它并不需要从关闭按钮中捕捉它。你想要达到什么目的? – pordi 2013-04-08 11:36:33
@PradipKT我想知道究竟是谁在发射结束事件。是this.close()调用取消按钮。 – 2013-04-08 12:21:18
::如果你想在交叉按钮点击的时候做任何明确的事情,那么你可以在OnFormClosing中做到这一点..但按照MSDN ..当我们使用this.Close(me.Close-VB)或点击十字按钮都调用OnFormClosing。你想要一个关于如何搭建OnFormClosing的例子吗?请告诉我。 – pordi 2013-04-08 12:26:08