开发者

WPF combobox SelectedValue binding to string

开发者 https://www.devze.com 2023-02-14 18:49 出处:网络
I\'ve bound my ComboBox SelectedValue to a string in my codebehind, but when the value is set, the s开发者_如何学Ctring becomes a ComboBoxItem. How do I just bind the selected value as a string?This i

I've bound my ComboBox SelectedValue to a string in my codebehind, but when the value is set, the s开发者_如何学Ctring becomes a ComboBoxItem. How do I just bind the selected value as a string?


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" .../>
0

精彩评论

暂无评论...
验证码 换一张
取 消