I’m trying to work out how I can alter the template depending on the size and number of items. This is very similar to the ribbon which dynamically changes depending on the size, or Windows 7 thumbnail of programs.
In this case, it’s an ItemTemplate of a ListBox and I want to reduce the size of the image or not display it, rather than having scroll bars.
<ListBox ItemsSource="{Binding Items}">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel>
<TextBlock Text="{Binding Title}" />
<Image Source="{Binding ImageUrl}" />
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
Thanks
You could set a style on the ListBox, which switches ItemTemplate based on the number of items.
The SizeConverter would be an IValueConverter which returns a size category based on the incoming count, the convert method could be something like this: