I’m using Rhino6. I change MRhinoUiDockBar to Dockbar using RhinoWindows.Controls.
public class MainViewDockBar : DockBar
{
public MainViewDockBar()
: base(MyRhinoCAMPlugIn.Instance, BarId, "WPF")
{
var window = new MainWindow();
ElementHost.EnableModelessKeyboardInterop(window);
this.SetContentControl(new WpfHost(window, null));
}
public static Guid BarId => new Guid("{c520731e-376a-4d82-975a-403664fca2fc}");
}
window xaml only have
<Grid>
<view:MainView x:Name="MainView"/>
</Grid>
But, MainView is not shown.
if I change this.SetContentControl(new WpfHost(window, null)) to this.SetContentControl(new WpfHost(new MainView(), null)) then main view is shown on dockbar.
Should I set only UserControl??
And even though change code, esc keydown event is not raised on child window of main view.
Have a look at the SampleCsWpf sample, which is part of the Rhino deveoper samples available on GitHub. The sample demonstrates how to embed a WPF control into a Rhino docking panel.
About SampleCsWpf I already read it, but it demonstrates embedding a WPF control into rhino panel.
But I want my plugin its own dockbar.
And my main purpose of this topic is child window which created in my wpf user control can’t receive escape key down event.
I already tried it through SampleCsWpf approach which embeds wpf control into a rhino docking panel.
But it also can’t raise escape key down event in child window.
My program scenario is that if user doubleclick some row of listview, then show new window for clicked row setting.
Then when focusing exist in a new window, if esc key down is raised, new window will be closed.
But esc key down event is not raised and only esc key up event is raised.
But because of specific logic, I need esc key down event.
In SampleCsWpf it use ShowSemiModal for show modal. And should I use ShowSemiModal for open new window??
Gettting escape key (and tab key) notifications from a modeless user interface presented in a DLL is a bit of a challenge. If you google “dll modeless dialog tab” you’ll see the issue comes frequently.
The only thing you can really do is hook the Windows keyboard. In our developer samples repository on GitHub, we have a WinForms sample that demonstrates this. you should be able to apply this workaround to WPF.