Accesing the value a bound WPF combobox

Apr 5, 2012 at 9:52 AM
Edited Apr 5, 2012 at 9:55 AM

I am trying to access the currently displayed text of a WPFComboBox. I used the following code snippet:


subscriber.MaritalStatus = subscriberWindow.CmbMaritalStatus.SelectedItemText;

However, the text returned is the name of the object bound to the currently selected item. i could not access the text that is displayed on screen. Any idea how can I achieve this?

I use White API to reference the combobox in question as a property, using the following code:



public WPFComboBox








return (WPFComboBox)_controller.GetControl(_thisWindow, "cmbMaritalStatus"




Apr 5, 2012 at 12:29 PM

The issue I reported above appeared to  be a bug in White. I found a work around after looking into old discussions. One have to click inside the combobox before being able to read the value of the currently selected item. The problem I faced with this work around is that my combobox is in readonly mode. I had to switch it to read/write mode, read its value and then switch it back again to readonly mode... very ugly.

Apr 10, 2012 at 7:50 AM

I had to do a expand/collapse action to get the selected text from the combobox. It works for me without any issues. Couldn't find another consistent way to get the value.