ComboBox所选项目为空

时间:2015-11-24 07:04:14

标签: c# wpf

我已经设置了一个实体的GenericCollection,其ID属性最初设置为0,并将组合框Itemsource设置为此通用集合。选定的值将Twoway绑定到另一个实体的财产。

当我保存数据时,Generic Collection(自定义集合)获取从数据库分配的ID。这也反映在组合框Itemsource中,但其选定的值为null。

XAML:

  <my1:ComboBox Name="cmbLHS" 
                Width="Auto" 
                Height="Auto" 
                Grid.Row="0" 
                Grid.Column="0"    
                IsEditable="False"
                SelectionChanged="cmbLHS_SelectionChanged"
                DisplayMemberPath="VARNAME" 
                SelectedValuePath="Code"
                ItemsSource="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}},Path=DataContext.BRPARMINPT}" 
                SelectedValue="{Binding LHSITEMSRCECDE,UpdateSourceTrigger=PropertyChanged,Mode=TwoWay}" />

即使在保存数据后,也会调用PropertyChanged,但是当我在SelectionChanged事件处理程序中检查Combobox SelectedItem时,它是null。

0 个答案:

没有答案
相关问题