本文介绍了父窗口关闭时关闭子窗口。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个WPF应用程序,我有3个窗口。



MainWindow,一个设置窗口和另一个用作dialogWindow的窗口(自定义无模式)



设置窗口仅从主窗口打开,如果在设置窗口中检测到2分钟不活动,则会自动关闭。 [这里还可以],但是如果我们说这个设置窗口会触发一个dialogWindow,如果检测到2分钟不活动,只有对话框仍在那里时关闭设置窗口。



如何关闭对话框窗口?



这就是我在设置窗口显示自定义对话框的方式



I have a WPF application which I have 3 windows.

The MainWindow, a Settings window and another window used as dialogWindow (custom modeless)

The Settings window opens only from mainwindow, if 2 minutes of inactivity is detected on Settings window this automatically close. [Upto here is ok], but if lets say this Settings Window trigerred a dialogWindow, if 2 minutes of inactivity is detected, only the Settings Window is being closed while the dialog is still there.

How can I close the dialog window as well?

This is how I am displaying the custom dialog on settings window

var customDialog = new CustomDialog("Incorrect Password!", CustomDialog.DialogButton.OK, CustomDialog.DialogImage.Error);
                    customDialogResult = customDialog.ShowCustomDialog();
                    if (customDialogResult == true)
                    {
                        customDialog.Close();
                        this.IsEnabled = true;
                    }





几乎在设置页面上检测到不活动时,它就是这样做。关闭



我尝试了什么:



试图实现一个事件但没有成功



And practically when inactivity is detected on settings page it just does this.close

What I have tried:

tried to implement an event but without sucess

推荐答案



这篇关于父窗口关闭时关闭子窗口。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-29 16:11
查看更多