Hi there,
I have a WPF app that has a ViewBox to display the items in my collection, diplaying a 2-column grid for my results.
What I'd like to do is, depending on the number of items in my collection, change the number of columns. E.g if there are < 10 items in the list, then show them in just 1 column; If there are 10 items in my list, then show them in 2 columns; If there are 20 items in my list, then show 3 columns.
Here's what I have at present:
<Viewbox>
<ItemsControl ItemsSource="{Binding myCollection}" Style="{DynamicResource myStyle}" />
</Viewbox>
Here's what myStyle currently defines:
<Style x:Key="myStyle" TargetType="{x:Type ItemsControl}">
<Setter Property=ItemsControl.ItemsPanel">
<Setter.Value>
<ItemsPanelTemplate>
<UniformGrid Columns="2" />
</ItemsPanelTemplate>
</Setter.Value>
</Setter>
</Style>
How can I make this code work to the above requirement? Thanks.