Exception:只能在创建 Window 并且作为对话框显示之后才能设置 DialogResult。

报错信息 1
InvalidOperationException: 只能在创建 Window 并且作为对话框显示之后才能设置 DialogResult。
StackTrace:
   在 System.Windows.Window.set_DialogResult(Nullable`1 value)
   在 DynamicClass.<>c__DisplayClass2.<OnWindowLoaded>b__1(Object s, CancelEventArgs e)
   在 System.ComponentModel.CancelEventHandler.Invoke(Object sender, CancelEventArgs e)
   在 System.Windows.Window.OnClosing(CancelEventArgs e)
   在 System.Windows.Window.WmClose()
   在 System.Windows.Window.WindowFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   在 System.Windows.Interop.HwndSource.PublicHooksFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   在 MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   在 MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
   在 System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   在 System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)

版本:1.44.19 2025-06-26 16:27 Microsoft Windows NT 10.0.26100.0