Automation for a WPF Custom Control that hosts a Windows Forms Host

I have my own WPF control based on ContentControl. The control displays the power system and makes its own drawing. I would like the elements of the power system to be accessible through the automation system. The tricky part is that the control itself has several ways to draw the grid. He can draw it using WPF, or he can draw it using DirectX. When it uses DirectX (preferred mode), the hosts manage WindowsFormsHost and randers on its HWND.

Now I have applied Automation Peer on my custom control and all the controls show Inspect well (very cool). But the problem occurs when trying to simulate a click on the automation infrastructure. AutomationElement.FromPoint always returns the windowsformshost automation element instead of my custom automation element.

When I look at the Automation Tree it looks like this:

Window
   pane   <- Windows forms host
      pane
   Titlebar
   Custom Control <- My Custom control that displays power grid
       Power grid elements

      

My guess is that the problem is that the panel appears in front of my custom control and the automation system believes it is covering my elements. How do I get around this? Is there any way I can tell Windows Forms Host not to add itself to the automation tree? Or be below my user control?

+3


source to share





All Articles