Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WPF combobox SelectedValue binding to string

Tags:

wpf

I've bound my ComboBox SelectedValue to a string in my codebehind, but when the value is set, the string becomes a ComboBoxItem. How do I just bind the selected value as a string?

like image 434
Aks Avatar asked Mar 03 '11 11:03

Aks


1 Answers

This is probably because you have ComboBoxItem objects as items in your ComboBox and string is a content of each ComobBoxItem. So try setting SelectedValuePath to "Content" on your ComboBox:

<ComboBox SelectedValuePath="Content" .../> 
like image 126
Pavlo Glazkov Avatar answered Sep 23 '22 02:09

Pavlo Glazkov