[英]Set the SelectedText of a ComboBox in WPF/MVVM
Heyo its me again, 嘿yo又是我
<ComboBox ItemsSource="{Binding EnterpriseList, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}"
SelectedItem="{Binding Enterprise, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}"
DisplayMemberPath="Name"
IsEditable="True"
IsEnabled="{Binding EnterpriseIsEnabled, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}"
Margin="3" Grid.Column="1">
does anyone know how i can bind the SelectedItem in this example to an Enterprise-Object? 有谁知道我如何将本示例中的SelectedItem绑定到企业对象? I can select the enterprise in the combobox like I want it, and it delivers a enterprise-object too, but when i reload the view, the text of the combobox doesnt get set to the name of the enterprise-object.
我可以根据需要在组合框中选择企业,它也可以提供企业对象,但是当我重新加载视图时,组合框的文本不会设置为企业对象的名称。
I hope I have explained my problem well enough, my english is not that good, I usually speak german ... 我希望我已经很好地解释了我的问题,我的英语不太好,我通常会说德语...
Your XAML look ok. 您的XAML看起来还不错。 Please be aware that the item your assign to
Enterprise
must be one from the list EnterpriseList
. 请注意,您分配给
Enterprise
的项目必须是EnterpriseList
列表中的一项。 The Combobox does compare object references not object contents eg the characters of strings. 组合框会比较对象引用而不是对象内容,例如字符串的字符。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.