Created
April 20, 2010 10:21
-
-
Save glebd/372271 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Runtime.InteropServices; | |
using System.Windows; | |
using System.Windows.Interop; | |
namespace Utility | |
{ | |
public static class UserHelper | |
{ | |
[DllImport("user32.dll")] | |
public static extern IntPtr GetActiveWindow(); | |
public static bool ShowDialog(Window dialog, Window owner) | |
{ | |
new WindowInteropHelper(dialog) | |
{ | |
Owner = owner != null | |
? new WindowInteropHelper(owner).Handle | |
: GetActiveWindow() | |
}; | |
var dialogResult = dialog.ShowDialog(); | |
return dialogResult.HasValue ? dialogResult.Value : false; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Based on http://sarafianalex.wordpress.com/2008/09/12/wpf-showdialog/