Skip to content

Instantly share code, notes, and snippets.

@glebd
Created June 8, 2010 16:37
Show Gist options
  • Save glebd/430281 to your computer and use it in GitHub Desktop.
Save glebd/430281 to your computer and use it in GitHub Desktop.
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