I have a custom WPF control based on ContentControl. The control displays power grid, and does its own drawing. I'd like to have elements of power grid available through automation framework.
The tricky part is that the control itself has multiple ways to draw power grid. It can draw it using WPF, or it can draw it using DirectX. When it's using DirectX (preferred mode), the control hosts
WindowsFormsHost and randers on its HWND.
Now I have implemented Automation Peer on my Custom control, and elements all show nicely in Inspect (very cool).
But the problem comes when trying to simulate a click through automation framework. AutomationElement.FromPoint always returns the windowsformshost automation element instead of my custom automation element.
When I look at Automation Tree it looks like this
I suppose the issue is that pane comes before my custom control, and automation framework belives that it is covering my elements.
How do I work around this? Can I somehow tell Windows Forms Host not to add itself to automation tree? Or to be below my custom control?
The tricky part is that the control itself has multiple ways to draw power grid. It can draw it using WPF, or it can draw it using DirectX. When it's using DirectX (preferred mode), the control hosts
WindowsFormsHost and randers on its HWND.
Now I have implemented Automation Peer on my Custom control, and elements all show nicely in Inspect (very cool).
But the problem comes when trying to simulate a click through automation framework. AutomationElement.FromPoint always returns the windowsformshost automation element instead of my custom automation element.
When I look at 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
I suppose the issue is that pane comes before my custom control, and automation framework belives that it is covering my elements.
How do I work around this? Can I somehow tell Windows Forms Host not to add itself to automation tree? Or to be below my custom control?