我有一个radcombobox,其属性在GotFocus和LostFocus事件之间的某处丢失了它的值。
XAML:
<telerik:RadComboBox x:Name="cboWoodSpecies"
FontSize="16" Margin="0,4,0,0" Background="#F6F8FA" BorderBrush="#D7D8DD"
ItemsSource="{Binding}" Text="{Binding woodSpecies, Mode=TwoWay}"
telerik:TextSearch.TextPath="WoodSpecies"
IsEditable="True" IsReadOnly="True" TabIndex="0"
Style="{DynamicResource RadComboBoxStyle3}" >
GotFocus事件:
Private Sub cboWoodSpecies_GotFocus(sender As Object, e As RoutedEventArgs) Handles cboWoodSpecies.GotFocus
BindComboBoxes.WoodSpecies(cboWoodSpecies) 'bind cbo to data
If thisOrder.woodSpecies <> String.Empty Then 'Property OK here!!
DisplayWoodSpeciesImage()
End If
End Sub
DisplayWoodSpeciesImage读取属性的值,但不会将其重置为Nothing。
引发LostFocus:
Private Sub cboWoodSpecies_LostFocus(sender As Object, e As RoutedEventArgs) Handles cboWoodSpecies.LostFocus
If thisOrder.woodSpecies <> String.Empty Then 'Property = Nothing. Why?!?!
'do stuff
End If
End Sub
我认为它与组合框本身有关。从组合中选择新项目不会导致问题。它正在填充导致问题的现有数据的组合。我必须重新选择该项以绕过错误。
话虽如此,有没有办法刷新组合框,以便它认为该项目已被再次选中?是否需要设置SelectedItem?
感谢您提供任何帮助或建议。
答案 0 :(得分:2)
尝试将SelectedValuePath
的{{1}}设置为&#34; WoodSpecies&#34;并将ComboBox
(而不是SelectedValue
属性)绑定到&#34; woodSpecies&#34;:
Text