I have a repeating data structure like this
public class Chapter
{
public string id { get; set; }
public string name { get; set; }
public List<BPage> pages { get; set; }
public List<SubChapter> chapters { get; set; }
}
public class SubChapter
{
public string name { get; set; }
public string id { get; set; }
public List<BPage> pages { get; set; }
public string ParentPageId { get; set; }
public List<SubChapter> chapters { get; set; }
}
public class BPage
{
public string name { get; set; }
public string label { get; set; }
}
Here is the xaml i am using , But this xaml is giving only one level of data back to me . Second level is missing completely
ie if Chapter 1 contains 2 subchapters and pages , then those info is missing
Chapter 1
page 1
page 2
Chapter 1.1
page 1a
page 1b
Chapter 1.2
page 2a
page 2b
And xaml is
<ListBox ItemsSource="{Binding}" Name="TOCView" ItemContainerStyle="{StaticResource ListBoxItemStyle}">
<ListBox.ItemTemplate>
<HierarchicalDataTemplate ItemsSource="{Binding chapters}">
<Expander>
<Expander.Header>
<BulletDecorator>
<Label Style="{StaticResource ResourceKey=ChapterHeadStyle}" Content="{Binding name}"></Label>
</BulletDecorator>
</Expander.Header>
<ItemsControl Margin="25,0,0,0" ItemsSource="{Binding pages}" >
<ItemsControl.ItemTemplate>
<DataTemplate>
<StackPanel>
<Button Tag="{Binding}" Click="btnNavigateToPage_Click" Style="{StaticResource ResourceKey=BookPageStyle}" Content="{Binding Path=label}" >
</Button>
</StackPanel>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</Expander>
</HierarchicalDataTemplate>
</ListBox.ItemTemplate>
</ListBox>