Chani Poz
Chani Poz

Reputation: 1463

listbox doesn't show displaymember

I have a ListBox, and it has a Binding to dtAtt, but when I run the app, the ListBox show the items with empty content.

Code:

Xaml:

<Expander Name="expandAtt" Header="Attachment">
    <ListBox x:Name="lstAtt" MouseDoubleClick="lstAtt_MouseDoubleClick" ItemsSource="{Binding}" DisplayMemberPath="Name">
    </ListBox>
</Expander>

C#:

    public DataTable  dtAtt;

    string sql = "SELECT Name FROM Item2Inv_Link";
    dtAtt = DataBase.GetTable(sql);
    lstAtt.ItemsSource = dtAtt.Select("Att_Pkg=0");

Upvotes: 0

Views: 286

Answers (1)

Mike Schwartz
Mike Schwartz

Reputation: 2212

You need to change your your source you're binding in the code just a bit. Try this:

lstAtt.ItemsSource = dtAtt.Select("Att_Pkg=0").CopyToDataTable().DefaultView;

Upvotes: 1

Related Questions