From 606aeda9f95f72ec800b1e183fc939272f4c20b0 Mon Sep 17 00:00:00 2001 From: brianlagunas_cp Date: Tue, 23 Nov 2010 03:06:53 +0000 Subject: [PATCH] [14735]: MessageBox: fixed ArgulmentNullException when showing a messageBox before a window has loaded. --- .../MessageBox/MessageBox.cs | 27 ++++++++++--------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/MessageBox/MessageBox.cs b/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/MessageBox/MessageBox.cs index 317dd405..1ef568e2 100644 --- a/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/MessageBox/MessageBox.cs +++ b/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/MessageBox/MessageBox.cs @@ -345,18 +345,21 @@ namespace Microsoft.Windows.Controls /// private Window CreateContainer() { - return new Window() - { - AllowsTransparency = true, - Background = Brushes.Transparent, - Content = this, - Owner = Window.GetWindow(ResolveOwner()), - ShowInTaskbar = false, - SizeToContent = System.Windows.SizeToContent.WidthAndHeight, - ResizeMode = System.Windows.ResizeMode.NoResize, - WindowStartupLocation = System.Windows.WindowStartupLocation.CenterOwner, - WindowStyle = System.Windows.WindowStyle.None - }; + var newWindow = new Window(); + newWindow.AllowsTransparency = true; + newWindow.Background = Brushes.Transparent; + newWindow.Content = this; + + var owner = ResolveOwner(); + if (owner != null) + newWindow.Owner = Window.GetWindow(owner); + + newWindow.ShowInTaskbar = false; + newWindow.SizeToContent = System.Windows.SizeToContent.WidthAndHeight; + newWindow.ResizeMode = System.Windows.ResizeMode.NoResize; + newWindow.WindowStartupLocation = System.Windows.WindowStartupLocation.CenterOwner; + newWindow.WindowStyle = System.Windows.WindowStyle.None; + return newWindow; } #endregion //Private