Hello!
When I try to test a WPF application I can get Informations about the Image but no informations about also available "Ellipse" elements. So I tried to test with a very small WPF application with a WPF ellipse (and a WPF button). Again I get no information about the ellipse (but had no problem with the button).
So why get I no information about the ellipse (System.Windows.Shapes.Ellipse) which is in the inheritance hierarchy under FrameworkElement (System.Windows.FrameworkElement) and get information about the image (System.Windows.Controls.Image) which also is in the inheritance hierarchy under FrameworkElement (System.Windows.FrameworkElement)?
Can you please tell what I must do that the spy (or the recorder) knows these WPF shapes (ellipse, line, ...) - or if these elements are not supported do you know when it is planned to do so?
Thank you very much.
WPF support of System.Windows.Shapes available?
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: WPF support of System.Windows.Shapes available?
Ranorex internally uses UIAutomation to interact with Silverlight/WPF applications. Shapes are not shown, because by default Shapes do not provide an UIAutomation interface (since they do not support user interaction). For Shapes to show up in the Ranorex element tree, you need to override the UIElement.OnCreateAutomationPeer method and return an AutomationPeer class.
Below is sample code that creates a custom Canvas control that overrides the OnCreateAutomationPeer method and is thus shown by Ranorex (I did that sample once for a customer, I'm pretty sure, you can adapt the sample for Shapes). I.e. if you want your Shapes to show up in Ranorex, (in your Silverlight/WPF application) replace the default Shapes with custom ones that inherit from the orignal Shapes and that override the OnCreateAutomationPeer method:
Alex
Ranorex Support Team
Below is sample code that creates a custom Canvas control that overrides the OnCreateAutomationPeer method and is thus shown by Ranorex (I did that sample once for a customer, I'm pretty sure, you can adapt the sample for Shapes). I.e. if you want your Shapes to show up in Ranorex, (in your Silverlight/WPF application) replace the default Shapes with custom ones that inherit from the orignal Shapes and that override the OnCreateAutomationPeer method:
public class RanorexVisibleCanvas : Canvas { protected override AutomationPeer OnCreateAutomationPeer() { return new FrameworkElementAutomationPeer(this); } }In your XAML file use this custom class instead of the default Canvas class:
<Window ... xmlns:src="clr-namespace:YourApplicationNameSpace" ...> ... <src:RanorexVisibleCanvas x:Name="myRanorexVisibleCanvas"> <Button>Click me!</Button> </src:RanorexVisibleCanvas> ... </Window>Regards,
Alex
Ranorex Support Team