The tool windows autohide option seems not to work properly when leaving the tool window

Docking/MDI for WPF Forum

Posted 4 years ago by Daniel Constantin - ModuleWorks GmbH
Version: 19.1.0685
Avatar

Hello,

I have an application in which I have a Ribbon window with tool windows and as a workspace inside the dock site I have a WindowsFormsHost control which hosts an OpenTK GLControl.

I have several minor issues:

  • The tool windows autohide option seems not to work properly when leaving the tool window and going to the GLControl. When going to other controls it will hide itself (desired behavior).
  • When the tool window is in the auto hide mode, the text block inside it does not seems to work with the selected theme (in this case metro dark).
  • The context menu workspace seems not to work also.

Kind regards,

Daniel

[Modified 4 years ago]

Comments (4)

Posted 4 years ago by Daniel Constantin - ModuleWorks GmbH
Avatar

I sent a sample to the 'support' address.

Kind regards,

Daniel

[Modified 4 years ago]

Answer - Posted 4 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

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!


Actipro Software Support

Posted 4 years ago by Daniel Constantin - ModuleWorks GmbH
Avatar

Thank you very much for the answer!

For the first issue I used the MouseEnter event ad worked perfectly for me.

One more question related to the Foreground TextBlock bug. When you say next build it will be next v19 or next v20 ?

Kind regards,

Daniel

Posted 4 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Daniel,

That update will be in the next v2019.1 maintenance release.


Actipro Software Support

The latest build of this product (v24.1.2) was released 2 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.