I have got here a little problem that I have to solve.
I have a ViewModel with a collection, so this collection holds objects of the type "Category", each Category has a List of "Channels".
So, I want to show the collection of the categories and directly at the bottom the list of all channels for each category.
Some thing like this:
How to do this in Xaml? With data bindings?
Seems you're using the wrong control for this kind of thing. You should be using a LongListSelector
since Grouping is already built in.
Here's a working example: How to display data in a grouped list in LongListSelector for Windows Phone 8
Launch the News Application for the Windows Phone 8 and you can see LongListSelector Group in action.
I tried it before like this, but it not worked! But now it is working this way!
<ListBox x:Name="AllCategoriesList" ItemsSource="{Binding categories}" Margin="10,0">
<ListBox.ItemTemplate>
<DataTemplate>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="50"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<TextBlock Text="{Binding name}" Grid.Row="0"></TextBlock>
<ListBox ItemsSource="{Binding channels}" Grid.Row="1">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel>
<TextBlock Text="{Binding name}"></TextBlock>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.