I have this view model bound to the DataContext of a UserControl:
public SomeViewModel : BaseViewModel
{
public IEnumerable<Products> Products { get; set; }
...
}
public class Products
{
public string Ident { get; set; }
public string Name { get; set; }
public ICollection<Provider> Providers { get; set; }
}
public class Provider
{
public string Name { get; set; }
public string Address { get; set; }
}
I want to bind the SomeViewModel.Products property to a list view so that the first two columns are the Ident and Name of the product (and then there is a set of columns for every Provider) like this:
I need the listview to have a dynamic number of columns depending on the number of items in the collection. If the collection has 2 Providers, the listview should have 6 columns (the first two which are bound to the Ident and Name properties of the Product, and 2 additional columns to the first Provider and another 2 columns to the second Provider).
This XAML code works to bind the first two columns to the Ident and Name properties of the Products object (the ListView ItemsSource is bound to the Products object in code-behind):
<ListView>
<ListView.View>
<GridView AllowsColumnReorder="true" ColumnHeaderToolTip="un tooltip pero de todos los headers de columnas joder...">
<GridViewColumn DisplayMemberBinding="{ Binding Ident }" Header="Ident" Width="50" />
<GridViewColumn DisplayMemberBinding="{ Binding Name }" Header="Name" Width="200" />
</GridView>
</ListView.View>
</ListView>
But how can I make the listview have aditional columns bound to properties in each of the items in the collection (to show Name and Address of each Provider)?
