Skip to content

Commit

Permalink
Merge pull request #2690 from cwensley/curtis/wpf-hide-child-windows-…
Browse files Browse the repository at this point in the history
…without-hiding-parents

Wpf: Clear owner before setting Visible to false
  • Loading branch information
cwensley authored Oct 2, 2024
2 parents 156c07e + 8b02221 commit fa2ca49
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions src/Eto.Wpf/Forms/WpfWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1079,18 +1079,21 @@ public void SetOwner(Window owner)
{
if (owner == null)
{
// Clear out WPF owner
Control.Owner = null;
return;

// If the owner was set to an HWND clear that out too.
var interop = windowInterop ?? new sw.Interop.WindowInteropHelper(Control);
interop.Owner = IntPtr.Zero;
}
var wpfWindow = owner.Handler as IWpfWindow;
if (wpfWindow != null)
else if (owner.Handler is IWpfWindow wpfWindow)
{
// Owner could be an HwndWindowHandler (or other) which sets owner differently
wpfWindow.SetOwnerFor(Control);
}
}

public double WpfScale
{
get { return dpiHelper?.WpfScale ?? 1f; }
}
public double WpfScale => dpiHelper?.WpfScale ?? 1f;

public float LogicalPixelSize
{
Expand Down Expand Up @@ -1119,10 +1122,18 @@ public override bool Visible
set
{
if (value)
{
// set owner back if we weren't visible beforehand
SetOwner(Widget.Owner);
Control.Show();
}
else
{
// hiding will hide entire owner chain, so clear that out before making it invisible.
SetOwner(null);
Control.Hide();
}
}
}
}
}

0 comments on commit fa2ca49

Please sign in to comment.