The view model contains a list with ObservableCollection<Book>
public class VM { public ObservableCollection<Book> bookList { get; set; } }
книга
in turn contains a список с рассказами
public class Book { public string Name { get; set;} public ObservableCollection<Story> storyList { get; set; } }
The story has a title and number of pages.
public class Story { public string Name {get;set;} public int CountPage {get;set;} }
The question is how to properly bind to the Name
and CountPage
?
<DataGrid ItemsSource="{Binding bookList}"> <DataGrid.Columns> <DataGridTextColumn Header="Рассказ" Binding="{Binding Name}"/> <DataGridTextColumn Header="Количество страниц" Binding="{Binding CountPage}"/> </DataGrid.Columns> </DataGrid>