diff options
author | Jose Medrano <josmed@microsoft.com> | 2022-04-07 14:19:19 +0300 |
---|---|---|
committer | Jose Medrano <josmed@microsoft.com> | 2022-04-07 14:19:19 +0300 |
commit | dc0bab08d2d176289699362426a13523430bcdfa (patch) | |
tree | c2276aab60ab9b7cd592c118cdc81371778bb432 | |
parent | 0ee962345da04614d27e63601b9372c11f633681 (diff) |
Ensures un associed both old parent dialog and new if it was already shownmore-window-fixes
-rw-r--r-- | Xwt.XamMac/Xwt.Mac/WindowFrameBackend.cs | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/Xwt.XamMac/Xwt.Mac/WindowFrameBackend.cs b/Xwt.XamMac/Xwt.Mac/WindowFrameBackend.cs index f96b4ce7..ae43d353 100644 --- a/Xwt.XamMac/Xwt.Mac/WindowFrameBackend.cs +++ b/Xwt.XamMac/Xwt.Mac/WindowFrameBackend.cs @@ -336,8 +336,16 @@ namespace Xwt.Mac Window.StyleMask &= ~NSWindowStyle.Miniaturizable; //we try to get the native object from the parameter if not we fallback into the real parent - NSWindow nParent = (ApplicationContext.Toolkit.GetNativeWindow(parent) as NSWindow) ?? Window.ParentWindow; - if (nParent != Window.ParentWindow) { + if (ApplicationContext.Toolkit.GetNativeWindow(parent) is NSWindow nParent && nParent != Window.ParentWindow) + { + // remove from the previous parent + if (Window.ParentWindow != null) + Window.ParentWindow.RemoveChildWindow(Window); + + // new parent has any associed window we remove it + if (nParent.ParentWindow != null) + nParent.ParentWindow.RemoveChildWindow(nParent); + Window.ParentWindow = nParent; } } |