【发布时间】:2014-12-04 12:55:52
【问题描述】:
如果我在 ComboBox 的依赖属性“Text”中加载字符串值。 ComboBox 没有将字符串值与 ItemsSource 对象配对,并且我没有填充 SelectedItem。
工具提示需要 SelectedItem!!
<ComboBox x:Name="FieldComboBox" IsEditable="True" IsTextSearchEnabled="True"
Text="{Binding Text, UpdateSourceTrigger=PropertyChanged}"
DisplayMemberPath="DataCode"
ItemsSource="{Binding FieldAlternative.FieldParts[0].DataItems}"
ToolTip="{Binding Path=SelectedItem.Description, ElementName=FieldComboBox}"/>
如果我有空文本并写,它工作正常。如果我用 Text 中的值打开了表单,我的 SelectedItem 为 null,但会显示值 Text。
如何强制将 Text 与 ItemsSource 中的对象配对以填充 SelectedValue 的任何解决方案,或者我的问题的任何更好的解决方案。
谢谢
【问题讨论】: