2016-04-30 11 views
0

Hey 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

+0

私はhttp://stackoverflow.com/questions/4902039/difference-between-selecteditem-selectedvalue-and-selectedvaluepathとhttp://stackoverflow.com/questions/3797034/confused-with-wpf-combobox-displaymemberpath -selectedvalue-and-selectedvaluepathはあなたに利益をもたらします。 –

答えて

0

SelectedValuePathからContactTypeIdを得るために私を助けてくださいを与えます。選択した項目の値(この場合はContactTypeId)はSelectedValueとして公開されています。それはあなたが読ませたい物です。

関連する問題