WPF wrappanel item alignment problem when scrolling
- by Jayho
Someone help me out pls.
I set a wrapPanel in a listbox itemPanelTemplate, Also, I already set the ScrollViewer.CanContentScroll="True".
But why the listbox items are not scrolling up/down by ITEM one by one? The scroll style is still by PIXEL.
Is anyone help me?
<Grid>
<ListBox x:Name="testListbox" ScrollViewer.CanContentScroll="True">
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel Width="200" ScrollViewer.CanContentScroll="True"/>
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
<ListBoxItem Background="LimeGreen" BorderBrush="Black" BorderThickness="3" ScrollViewer.CanContentScroll="True">
<Image Height="50" Width="80" ScrollViewer.CanContentScroll="True"/>
</ListBoxItem>
<ListBoxItem Background="LimeGreen" BorderBrush="Black" BorderThickness="3" ScrollViewer.CanContentScroll="True">
<Image Height="50" Width="80" ScrollViewer.CanContentScroll="True"/>
</ListBoxItem>
<ListBoxItem Background="LimeGreen" BorderBrush="Black" BorderThickness="3" ScrollViewer.CanContentScroll="True">
<Image Height="50" Width="80" ScrollViewer.CanContentScroll="True"/>
</ListBoxItem>
<ListBoxItem Background="LimeGreen" BorderBrush="Black" BorderThickness="3" ScrollViewer.CanContentScroll="True">
<Image Height="50" Width="80" ScrollViewer.CanContentScroll="True"/>
</ListBoxItem>
<ListBoxItem Background="LimeGreen" BorderBrush="Black" BorderThickness="3" ScrollViewer.CanContentScroll="True">
<Image Height="50" Width="80" ScrollViewer.CanContentScroll="True"/>
</ListBoxItem>
<ListBoxItem Background="LimeGreen" BorderBrush="Black" BorderThickness="3" ScrollViewer.CanContentScroll="True">
<Image Height="50" Width="80" ScrollViewer.CanContentScroll="True"/>
</ListBoxItem>
<ListBoxItem Background="LimeGreen" BorderBrush="Black" BorderThickness="3" ScrollViewer.CanContentScroll="True">
<Image Height="50" Width="80" ScrollViewer.CanContentScroll="True"/>
</ListBoxItem>
<ListBoxItem Background="LimeGreen" BorderBrush="Black" BorderThickness="3" ScrollViewer.CanContentScroll="True">
<Image Height="50" Width="80" ScrollViewer.CanContentScroll="True"/>
</ListBoxItem>
<ListBoxItem Background="LimeGreen" BorderBrush="Black" BorderThickness="3" ScrollViewer.CanContentScroll="True">
<Image Height="50" Width="80" ScrollViewer.CanContentScroll="True"/>
</ListBoxItem>
<ListBoxItem Background="LimeGreen" BorderBrush="Black" BorderThickness="3" ScrollViewer.CanContentScroll="True">
<Image Height="50" Width="80" ScrollViewer.CanContentScroll="True"/>
</ListBoxItem>
<ListBoxItem Background="LimeGreen" BorderBrush="Black" BorderThickness="3" ScrollViewer.CanContentScroll="True">
<Image Height="50" Width="80" ScrollViewer.CanContentScroll="True"/>
</ListBoxItem>
<ListBoxItem Background="LimeGreen" BorderBrush="Black" BorderThickness="3" ScrollViewer.CanContentScroll="True">
<Image Height="50" Width="80" ScrollViewer.CanContentScroll="True"/>
</ListBoxItem>
<ListBoxItem Background="LimeGreen" BorderBrush="Black" BorderThickness="3" ScrollViewer.CanContentScroll="True">
<Image Height="50" Width="80" ScrollViewer.CanContentScroll="True"/>
</ListBoxItem>
<ListBoxItem Background="LimeGreen" BorderBrush="Black" BorderThickness="3" ScrollViewer.CanContentScroll="True">
<Image Height="50" Width="80" ScrollViewer.CanContentScroll="True"/>
</ListBoxItem>
<ListBoxItem Background="LimeGreen" BorderBrush="Black" BorderThickness="3" ScrollViewer.CanContentScroll="True">
<Image Height="50" Width="80" ScrollViewer.CanContentScroll="True"/>
</ListBoxItem>
<ListBoxItem Background="LimeGreen" BorderBrush="Black" BorderThickness="3" ScrollViewer.CanContentScroll="True">
<Image Height="50" Width="80" ScrollViewer.CanContentScroll="True"/>
</ListBoxItem>
</ListBox>
</Grid>