In the constructor of a WPF Window I am setting its owner to be a WinForm using WindowInteropHelper
. After setting this, the Owner
property of the WPF Window is still null.
public WpfWindow(System.Windows.Forms.Form owner)
{
if (owner != null)
{
var helper = new System.Windows.Interop.WindowInteropHelper(this);
helper.Owner = owner.Handle;
var Owner.Width; // Owner is null
}
}
I need to get location information about the parent and hope to use Owner.Left
, Owner.Width
, etc. whether the owner is a WPF Window or a WinForm.
Is this possible? If not, what options do I have other than keeping a ref to the WinForm inside my WPF class?