tags:

views:

82

answers:

2

In WPF ComboBox does not have SelectedText property.

Is there a way to achieve the same functionality as TextBox SelectedText has in WPF

+1  A: 

You can get access to the ComboBox's TextBox by using:

var edit = (TextBox)myCombo.Template.FindName("PART_EditableTextBox", myCombo);

Then you can access the SelectedText property of that TextBox:

var selectedText = edit.SelectedText;
codekaizen
Thanks. Its working Perfect
Ronak
A: 

Because WPF is "lookless" you can display your combobox items in any manner you wish. there may or may not be a text item.

MyCombo.SelectedText doesn't make any sense if you are, for example, display icons in there.

What you want is ComboBox.SelectedItem and then access your object. for example, if you are using a backing list of "People" objects.... MyComboBox.SelectedItem.PersonName

typically, the SelectedItem is databound to your object model or to another control.

Muad'Dib
I got the answer in the above Post. I need SelectedText from the ComboBox to process them further, When ComboBox is in Edit mode.
Ronak