I would like to have a layout like Netflix when showing the movie posters:
Category
Poster1 Poster2 Poster3
Category 2
Poster1 Poster2 Poster3
I came up with this:
<ItemsControl Name="dataControl" ItemsSource="{Binding}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<StackPanel>
<TextBlock Width="100" Height="50" FontSize="14" Text="{Binding Key}"></TextBlock>
<ItemsControl Name="dataControl" ItemsSource="{Binding Value}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<Button Content="{Binding MovieName}" Width="100" Height="100"/>
</StackPanel>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</StackPanel>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
It's bound to a Dictionary that's why you have Key and Value as bindings for the controls. Sadly, the end result is this:
Note that the "movie posters" instead of being aligned horizontally, they are aligned vertically.
It seems to create a stack of one item per "row", but I don't know how to tell it to create a one horizontal stack for all the related items.
This is the source:
Dictionary<string, List<Movie>> Source;
And this is the Movie class:
public class Movie
{
public string MovieName { get; set; }
}
And the control is binded this way:
dataControl.ItemsSource = Source;