我將數據庫表的主鍵綁定到組合框的selectedIndex。問題發生在主鍵從1開始,但selectedIndex從0開始接受。我的意思是,當我想在數據庫中看到ID = 1的項目時,因爲它被列爲索引爲0的組合框中的第一個元素,它顯示第二個元素在組合框中被認爲ID = 1的列表中。任何人都可以幫助我解決這個問題嗎?Combobox中的數據綁定
在此先感謝。 這裏是我的組合框:
<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是一個屬性,爲什麼不在那裏進行計算? – 2010-08-26 07:18:37