I have WPF project based on MVVM. In my view I have the next ListBox
<ListBox BorderBrush="#6797c8" BorderThickness="2"
ItemsSource="{Binding Path=CategoriesDS}"
DisplayMemberPath="MainCategories/Category"/>
And this is my code at 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"));
}
}
}
My DataSet contains 2 tables and the first table (“MainCategories”) contains 3 rows.
When I run my app I’m seeing just the first row of “MainCategories” table.
Why is the ListBox showing just 1 row? I want to show the entire table.
Thanks
You’ll need to bind to the table directly. You can create another property that just accesses the
CategoriesDSproperty and then bind against the new property:or
XAML