[英]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. 我有一个
ListBox
,并且它具有dtAtt
的Binding
,但是当我运行该应用程序时,ListBox会显示内容为空的项目。
Code: 码:
Xaml: XAML:
<Expander Name="expandAtt" Header="Attachment">
<ListBox x:Name="lstAtt" MouseDoubleClick="lstAtt_MouseDoubleClick" ItemsSource="{Binding}" DisplayMemberPath="Name">
</ListBox>
</Expander>
C#: C#:
public DataTable dtAtt;
string sql = "SELECT Name FROM Item2Inv_Link";
dtAtt = DataBase.GetTable(sql);
lstAtt.ItemsSource = dtAtt.Select("Att_Pkg=0");
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;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.