Hi Daniel,
Thanks for the sample project.
1) This is due to any interop controls not reporting WPF focus events, which we have to use to know when to close the auto-hide popup. Per the Interop Compatibility documentation topic, you should set the attached docking:InteropFocusTracking.IsEnabled="True" property on anything like a WindowsFormsHost. That tries help with focus changes when the HwndHost (base class) is within a tab. If you surrounded your ViewportContainer with a TabbedMdiHost/TabbedMdiContainer/DocumentWindow, then the auto-hide popup will close when you click the viewport. In your case though, I was able to get it working with adding this to your TestOpenGLViewer logic. Note the FindWPFHost code came from this SO post (https://stackoverflow.com/questions/44055831/get-wpf-window-from-windows-forms-control-in-windowsformshost).
protected override void OnMouseDown(MouseEventArgs e) {
base.OnMouseDown(e);
var dockSite = VisualTreeHelperExtended.GetAncestor<DockSite>((WindowsFormsHost)FindWPFHost(this));
if (dockSite != null) {
dockSite.PrimaryDockHost.CloseAutoHidePopup(true, true);
this.Focus();
}
}
private static WindowsFormsHost FindWPFHost(Control control) {
if (control.Parent != null)
return FindWPFHost(control.Parent);
else {
string typeName = "System.Windows.Forms.Integration.WinFormsAdapter";
if (control.GetType().FullName == typeName) {
Assembly adapterAssembly = control.GetType().Assembly;
Type winFormsAdapterType = adapterAssembly.GetType(typeName);
return (WindowsFormsHost)winFormsAdapterType.InvokeMember("_host", BindingFlags.NonPublic | BindingFlags.GetField | BindingFlags.Instance, null, control, new string[0], null);
}
else
throw new Exception("The top parent of a control within a host should be a System.Windows.Forms.Integration.WinFormsAdapter, but that is not what was found. Someone should propably check this out.");
}
}
2) This appeared to be a problem with ToolWindowContainer not setting a Foreground. We will default it to this in the next build:
<Setter Property="Foreground" Value="{DynamicResource {x:Static themes:AssetResourceKeys.ControlForegroundNormalBrushKey}}" />
3) I don't believe the context menu issue is anything we are doing. If you set the ViewportContainer.Background to Transparent and remove the interop control from being inserted (to cover the container's background), then it works.
I hope that helps!