Reputation: 1347
I want to implement an horizontal ListView
which can have multiple lines, like the file explorer:
I found that I have to use StackPanel
for the ItemPanelTemplate
here, but I prefer to have multiple lines instead of the horizontal scrollbar.
I think that the idea is when the StackPanel width reaches the ListView width, go the next line/create a new StackPanel. I don't know if it's correct, but maybe it can help to understand what am I looking for.
How can I implement this?
Upvotes: 2
Views: 1793
Reputation: 550
<ListBox ItemsSource="{Binding Files}" ScrollViewer.HorizontalScrollBarVisibility="Disabled">
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel />
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
</ListBox>
Upvotes: 0
Reputation: 109
Use a WrapPanel
and specify the width
.
<ListView ItemsSource="your-source">
<ListView.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel width="1200" />
</ItemsPanelTemplate>
</ListView.ItemsPanel>
</ListView>
Upvotes: 1
Reputation: 143
You need to use a WrapPanel
instead of a StackPanel
as ItemsPanelTemplate
.
<ListView ItemsSource="{Binding xxx}">
<ListView.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel />
</ItemsPanelTemplate>
</ListView.ItemsPanel>
</ListView>
Upvotes: 4