1
我有基于MVVM的WPF项目。在我看来,我的下一个列表框将数据集绑定到仅显示1条记录的列表框
<ListBox BorderBrush="#6797c8" BorderThickness="2"
ItemsSource="{Binding Path=CategoriesDS}"
DisplayMemberPath="MainCategories/Category"/>
这是我的ViewModel代码:
private DataSet categoriesDS;
public DataSet CategoriesDS
{
get
{
if (categoriesDS == null)
{
categoriesDS = _dal.GetCategoriesTables();
}
return categoriesDS;
}
set
{
categoriesDS = value;
if (this.PropertyChanged != null)
{
this.PropertyChanged(this,
new PropertyChangedEventArgs("CategoriesDS"));
}
}
}
我DataSet包含2个表和第一个表(“MainCategories”)包含3行。 当我运行我的应用程序时,我只看到“MainCategories”表的第一行。
为什么ListBox只显示1行?我想要显示整个表格。
谢谢
尝试返回一个表。不是数据集。 – Paparazzi