0
嘿,我有一個關於從ContactType獲取ContactTypeId的問題。這是具有ID的對象:SelectedValuePath不返回一個ID
public class ContactType
{
public int ContactTypeId { get; set; }
public string ContactTypeValue { get; set; }
public int ContactId { get; set; }
public DateTime? Added { get; set; }
public DateTime? Updated { get; set; }
public DateTime? Deleted { get; set; }
}
我寫了一個帶有列表框的WPF應用程序。
<ComboBox x:Name="ContactTypeComboBox" HorizontalAlignment="Left" Margin="110,68,0,0" VerticalAlignment="Top" Width="120" ItemsSource="{Binding ContactTypes}" DisplayMemberPath="ContactTypeValue" SelectedValuePath="ContactTypeId" />
如果我得到所選值路徑不會給該對象的ContactTypeId。它只是給出了一個字符串「ContactTypeId」
請幫我從ContactType
我認爲http://stackoverflow.com/questions/4902039/difference-between-selecteditem-selectedvalue-and-selectedvaluepath和http://stackoverflow.com/questions/3797034/confused-with-wpf-combobox-displaymemberpath -selectedvalue-and-selectedvaluepath將使你受益。 –