Browse Source

Wizard: fixed closing parent window exception when window was not shown with ShowDialog.

pull/1645/head
brianlagunas_cp 15 years ago
parent
commit
d881eead18
  1. 20
      ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/Wizard/Implementation/Wizard.cs

20
ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/Wizard/Implementation/Wizard.cs

@ -2,6 +2,7 @@
using System.Windows; using System.Windows;
using System.Windows.Controls; using System.Windows.Controls;
using System.Windows.Input; using System.Windows.Input;
using System.Windows.Interop;
namespace Microsoft.Windows.Controls namespace Microsoft.Windows.Controls
{ {
@ -108,7 +109,7 @@ namespace Microsoft.Windows.Controls
get { return (double)GetValue(ExteriorPanelMinWidthProperty); } get { return (double)GetValue(ExteriorPanelMinWidthProperty); }
set { SetValue(ExteriorPanelMinWidthProperty, value); } set { SetValue(ExteriorPanelMinWidthProperty, value); }
} }
public static readonly DependencyProperty FinishButtonClosesWindowProperty = DependencyProperty.Register("FinishButtonClosesWindow", typeof(bool), typeof(Wizard), new UIPropertyMetadata(true)); public static readonly DependencyProperty FinishButtonClosesWindowProperty = DependencyProperty.Register("FinishButtonClosesWindow", typeof(bool), typeof(Wizard), new UIPropertyMetadata(true));
public bool FinishButtonClosesWindow public bool FinishButtonClosesWindow
@ -370,20 +371,11 @@ namespace Microsoft.Windows.Controls
Window window = Window.GetWindow(this); Window window = Window.GetWindow(this);
if (window != null) if (window != null)
{ {
try //we can only set the DialogResult if the window was opened as modal with the ShowDialog() method. Otherwise an exception would occur
{ if (ComponentDispatcher.IsThreadModal)
window.DialogResult = dialogResult; window.DialogResult = dialogResult;
}
catch (InvalidOperationException) window.Close();
{
//DialogResult can be set only after Window is created and shown as dialog.
//So if the Window is not shown as a dialog then an exception would occur. Therefore
//let's just swallow the exception
}
finally
{
window.Close();
}
} }
} }

Loading…
Cancel
Save