OPTION 1
IWin32Window only expects a Handle property, which is not too difficult to implement since you already have the IntPtr. Create a wrapper class that implements IWin32Window:
public class WindowWrapper : System.Windows.Forms.IWin32Window { public WindowWrapper(IntPtr handle) { _hwnd = handle; } public WindowWrapper(Window window) { _hwnd = new WindowInteropHelper(window).Handle; } public IntPtr Handle { get { return _hwnd; } } private IntPtr _hwnd; }
You would then get your IWin32Window like this:
IWin32Window win32Window = new WindowWrapper(new WindowInteropHelper(this).Handle);
or (in response to KeithS' suggestion):
IWin32Window win32Window = new WindowWrapper(this);
OPTION 2 (thx to Scott Chamberlain's comment)
Use the existing NativeWindow class, which implements IWin32Window:
NativeWindow win32Parent = new NativeWindow(); win32Parent.AssignHandle(new WindowInteropHelper(this).Handle);