【发布时间】:2010-08-26 07:14:39
【问题描述】:
我将数据库表的主键绑定到组合框的 selectedIndex。问题出现在主键从 1 开始但 selectedIndex 从 0 接受的情况下。我的意思是,当我想在数据库中查看 ID=1 的项目时,因为它被列为索引为 0 的组合框中的第一个元素,它显示第二个元素在列表中,组合框中的 ID=1。谁能帮我解决这个问题?
提前致谢。 这是我的组合框:
<ComboBox SelectedIndex="{Binding SC.User1.UserID, UpdateSourceTrigger=PropertyChanged }"
IsSynchronizedWithCurrentItem="True"
x:Name="proxyResponsibleUserCmb" ItemsSource="{Binding Users, Mode=OneTime}"
SelectedItem="{Binding SC.User1.FullName, ValidatesOnDataErrors=True,
UpdateSourceTrigger=PropertyChanged}"
Validation.ErrorTemplate="{x:Null}"
Height="23"
VerticalAlignment="Top"
HorizontalAlignment="Left"
Width="118"
Margin="184,3,0,0"
Grid.Row="0"
Grid.Column="1"/>
【问题讨论】:
-
你能提供一些代码吗?例如。如果您的 selectedIndex 是一个属性,为什么不在那里进行计算?
标签: wpf data-binding combobox