【发布时间】:2016-04-30 14:33:53
【问题描述】:
嘿,我有一个关于从 ContactType 获取 ContactTypeId 的问题。这是具有 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" />
如果我得到 Selected 值路径不提供来自该对象的 ContactTypeId。它只给出一个字符串“ContactTypeId”
请帮我从 ContactType 获取一个 ContactTypeId
【问题讨论】:
标签: wpf data-binding