public static void SetParentWindowToNull(this Window window) { if (window.Owner != null) { window.Owner = null; return; } Win32Helper.SetOwner((new WindowInteropHelper(window)).Handle, IntPtr.Zero); }
public static void SetParentToMainWindowOf(this Window window, Visual element) { IntPtr intPtr; Window window1 = Window.GetWindow(element); if (window1 != null) { window.Owner = window1; return; } if (element.GetParentWindowHandle(out intPtr)) { Win32Helper.SetOwner((new WindowInteropHelper(window)).Handle, intPtr); } }
public static void SetParentToMainWindowOf(this Window window, Visual element) { var wndParent = Window.GetWindow(element); if (wndParent != null) { window.Owner = wndParent; } else { IntPtr parentHwnd; if (GetParentWindowHandle(element, out parentHwnd)) { Win32Helper.SetOwner(new WindowInteropHelper(window).Handle, parentHwnd); } } }