I'm building an assembly that runs as an "add-on" to a vendor's Outlook add-in. When it is time for me to execute my "action", I have to put up a simple window with a few simple controls. The vendor's add-in provides me with the parent window's integer handle. I am able to put up a form pretty easily with WinForms by adding are reference to System.Windows.Forms from my assembly and with the following code:
FrmHistoryDisplay frm = new FrmHistoryDisplay();
frm.ShowDialog(new ParentWindowWrapper(_parentWindowHandle));
where ParentWindowWrapper is a shim class around the window handle I'm given
private class ParentWindowWrapper : IWin32Window {
private int _parentWindowHandle;
public ParentWindowWrapper(int parentWindowHandle) {
_parentWindowHandle = parentWindowHandle;
}
public IntPtr Handle {
get { return new IntPtr(_parentWindowHandle); }
}
}
The Form's ShowDialog method takes an IWin32Window implementor to wrap the parent's window handle.
This all works and seems simple enough. I was just wondering whether something similar can be done with a WPF window rather than a WinForm Form? Should I care?