考虑我有一个键值对集合(例如Key=MSFT,Value=MSFT Microsoft),我将其绑定到ComboBox上,并且使用DisplayMemeberPath=Value。需要完成以下内容:
选择项目后,只需在组合框中显示Key,
用户还可以在组合框中输入全新的值。
我无法想出同时支持这两个功能的解决方案。解决其中一个会破坏另一个。
<ComboBox IsTextSearchEnabled="True" Name="cmbBrokers" IsEditable="True"
ItemsSource="{Binding BrokerCodes}" SelectedValuePath="Key"
DisplayMemberPath="Value" Text="{Binding SelectedBroker, Mode=TwoWay}">