I have a custom WinForms control that displays some graphics. I need to overlay an InkCanvas
on top of this control. The InkCanvas
should be "see through" (transparent background, visible ink). This InkCanvas
allows the user to sketch on the graphics being displayed.
I know about the airspace issue in WPF/WinForms interop (the fact that WinForms elements hosted in a WPF window will always stay on top of all other components). So obviously I cannot achieve the desired effects in WPF. I decided to go about the problem the other way around (host an InkCanvas
in a WinForms form and overlay the InkCanvas
on my custom control).
The problem is that the WinForms ElementHost
cannot be made "see through" (no transparency can be set). I tried deriving ElementHost with the following override
protected override CreateParams CreateParams
{
get
{
const int WS_EX_TRANSPARENT = 0x20;
CreateParams cp = base.CreateParams;
cp.ExStyle = cp.ExStyle | WS_EX_TRANSPARENT;
return cp;
}
}
But this will make the whole thing completely transparent (the sketches are not visible any more).
How can I have the "see through" InkCanvas
with visible ink overlayed on the WinForms control?
Based on the comments and lack of answers, we can safely assume that what I want to do is impossible unless we do the "window layering" hack that @Hans Passant mentioned.