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