【发布时间】:2009-11-18 11:42:16
【问题描述】:
我的 wpf 应用程序中发生了一件非常奇怪的事情。
每次我关闭某些东西(对话框、窗口等)时,整个应用程序都会关闭,而不仅仅是关闭的窗口/对话框。
这不仅发生在我直接调用 Close 方法时,还发生在元素自行关闭时,例如:当我在 Dialog 上单击“确定”并从 ShowDialog() 方法返回时。
此外,这不会立即发生,而只会在发生关闭事件的方法时发生。这是一个更好地解释它的例子:
Public Sub addNewCanvas(ByVal sender As Object, ByVal e As ExecutedRoutedEventArgs)
Dim dlg As New addCanvasDgBox
Dim result As Nullable(Of Boolean) = dlg.ShowDialog
'The following if is executed, and so is the addCanvas() method
If (result = True) Then
addCanvas()
End If
End Sub
'Here comes the problem: efter the routine is ended instead of returning
'to the normal execution, the entire App.Run() method returns, closing the application
我真的不明白为什么会发生这种情况......没有引发异常,输出日志或visualStudio无话可说,所有变量都正确赋值。
如果你们有任何想法,请告诉我!它快把我逼疯了! 提前致谢。
大师_T
【问题讨论】:
标签: .net wpf vb.net visual-studio