Wpf ComboBox with data bindings

Technology specific object identification, supported applications, web technologies, and 3rd party controls.
RobinHellen
Posts: 9
Joined: Tue Sep 13, 2011 9:42 am

Wpf ComboBox with data bindings

Post by RobinHellen » Tue Apr 17, 2012 3:03 pm

Ranorex is producing the wrong text for the items in a combobox in our application.
I have attached a minimal example. For the upper combo, the text of every item is seen as "WpfCombos.DummyConnectionProperties", but for the lower everything is correct.
If I add a ToString method to the DummyConnectionProerties class then I see that instead.

Essentially the problem is that Ranorex is showing me the wrong property of the object to which the list element is bound. It should show me the text that is actually rendered to screen
(In the actual AUT I cannot add a ToString to the underlying class as it comes from an external library)
Attachments
WpfCombos.zip
(67.16 KiB) Downloaded 218 times

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Wpf ComboBox with data bindings

Post by Support Team » Wed Apr 18, 2012 10:33 am

Hi,

Ranorex is not able to get the element by its name because the ToString() method was uncommented.
If you enable the
public override string ToString()
{
    return m_DbName;
}
method in your WpfCombos.DummConnectionProperties Ranorex is able to detect the text instead of the type.

Regards,
Peter
Ranorex Team
.
Image

RobinHellen
Posts: 9
Joined: Tue Sep 13, 2011 9:42 am

Re: Wpf ComboBox with data bindings

Post by RobinHellen » Wed Apr 18, 2012 10:54 am

HI Peter,

I understand that Ranorex will show me the DatabaseName value if I implement the .ToString() method. However, I can't make that change in our application as the class that is being bound comes from an external library. My point rather is that I expect the Text properties of Ranorex objects to be the text displayed to the screen.

The XAML for the combobox specifies that the DatabseName property is to be printed instead of the string representation, so that should be reflected in the representation Ranorex gives me.
<ComboBox SelectedItem="{Binding SelectedDatabase, Mode=TwoWay}" DisplayMemberPath="DatabaseName" ItemsSource="{Binding Path=Databases}" Grid.Column="1" Grid.Row="2" Height="23" HorizontalAlignment="Left"
VerticalAlignment="Top" Width="212" Margin="6,0,0,0" Name="m_DatabaseCombo" SelectionChanged="m_DatabaseCombo_SelectionChanged" />



Robin

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Wpf ComboBox with data bindings

Post by Support Team » Wed Apr 18, 2012 4:37 pm

RobinHellen wrote:The XAML for the combobox specifies that the DatabseName property is to be printed instead of the string representation, so that should be reflected in the representation Ranorex gives me.
The problem is that Ranorex uses Microsoft's UI Automation (UIA) technology in order to recognize WPF applications (i.e. it is not doing any visual text recognition or similar methods to get the text inside the combobox). And it seems there is a bug in the UIA implementation of the combobox not respecting the "DisplayMemberPath" property.

Consequently, the only way to fix this problem is to contact the developers of the control and ask them to implement the "ToString" method :?

Regards,
Alex
Ranorex Team
.
Image