0
votes

I am looking for a custom ListView control which arranges the items horizontally and if the max width is reached, add the item to the next row.

The WrapGrid as ListView.ItemsPanel doesn't work because it uses equal width for each item (grid structure).

The WrapPanel from the WinRT XAML Toolkit has no ItemTemplate and I cannot use binding due to missing ItemSource property.

Could I write my own ListView implementation with wrapping? Which methods do I need to override?

1
The items have a different width and should be displayed in a row and then wraped in the next row. - zrkl
This requires to include custom ColSpan and RowSpan properties in my model and I need to calculate the column and rows manually - zrkl

1 Answers

0
votes

The solution is to use the WrapPanel from WinRT XAML Toolkit inside the ListViews ItemsPanel:

            <ListView x:Name="Keywords" SelectionMode="Multiple" ItemContainerStyle="{ThemeResource ListViewItemStyle}">
                <ListView.ItemTemplate>
                    <DataTemplate>
                        <StackPanel>
                            <TextBlock Text="{Binding}" Style="{ThemeResource ListViewItemSubheaderTextBlockStyle}" />
                        </StackPanel>
                    </DataTemplate>
                </ListView.ItemTemplate>

                <ListView.ItemsPanel>
                    <ItemsPanelTemplate>
                        <toolkit:WrapPanel />
                    </ItemsPanelTemplate>
                </ListView.ItemsPanel>
            </ListView>