Wpf RadCombobox属性在GotFocus和LostFocus之间丢失值
我有一个radcombobox,它的属性在GotFocus和LostFocus事件之间的某个地方丢失了它的值 XAML:Wpf RadCombobox属性在GotFocus和LostFocus之间丢失值,wpf,telerik,radcombobox,Wpf,Telerik,Radcombobox,我有一个radcombobox,它的属性在GotFocus和LostFocus事件之间的某个地方丢失了它的值 XAML: GotFocus事件: Private Sub cboWoodSpecies_GotFocus(sender As Object, e As RoutedEventArgs) Handles cboWoodSpecies.GotFocus BindComboBoxes.WoodSpecies(cboWoodSpecies) 'bind cbo to data
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
私有子cboWoodSpecies\u GotFocus(发送方作为对象,e作为routedEventTargets)处理cboWoodSpecies.GotFocus
BindComboBox.WoodSpecies(cboWoodSpecies)将cbo绑定到数据
如果thisOrder.woodSpecies字符串为空,则“此处的属性确定!!
DisplayWoodSpeciesImage()
如果结束
端接头
DisplayWoodSpeciesImage读取属性值,但不会将其重置为零
损失焦点:
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
私有子cboWoodSpecies\u LostFocus(发送方作为对象,e作为RoutedEventArgs)处理cboWoodSpecies.LostFocus
如果thisOrder.woodSpecies String.Empty,则'Property=Nothing。为什么?
“做事
如果结束
端接头
我认为这与组合框本身有关。从组合中选择新项目不会导致问题。导致问题的是用现有数据填充组合。我必须重新选择项目以绕过错误
也就是说,有没有办法刷新组合框,使其认为该项已被再次选中?是否需要设置SelectedItem的某些内容
感谢您的帮助或建议。尝试将
组合框的SelectedValuePath
设置为“WoodSpecies”,并将SelectedValue
(而不是Text
属性)绑定为“WoodSpecies”:
bindcomboxes.WoodSpecies方法的具体功能是什么?它是如何实现的?比如:“Public Class bindcomboxes Public Shared Sub WoodSpecies(thisCombo As RadComboBox)”之类的东西da.Fill(dt)thisCombo.ItemsSource=dt.DefaultView thisCombo.IsTextSearchEnabled=True thisCombo.StaysOpenOneEdit=True Catch ex As Exception’stuff Finally End Try End SubAnd什么类型的属性是“woodSpecies”?私有_woodSpecies作为字符串公共属性woodSpecies作为字符串获取返回_WoodSpeciesEnd Get Set(值作为字符串)_woodSpecies=值NotifyPropertyChanged(“woodSpecies”)End Set End Property数据表是否有一个名为“woodSpecies”的列?
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
<telerik:RadComboBox x:Name="cboWoodSpecies"
FontSize="16" Margin="0,4,0,0" Background="#F6F8FA" BorderBrush="#D7D8DD"
ItemsSource="{Binding}"
SelectedValuePath="WoodSpecies"
SelectedValue="{Binding woodSpecies, Mode=TwoWay}"
telerik:TextSearch.TextPath="WoodSpecies"
IsEditable="True" IsReadOnly="True" TabIndex="0"
Style="{DynamicResource RadComboBoxStyle3}" >