WPF wrappanel item alignment problem when scrolling

Posted by Jayho on Stack Overflow See other posts from Stack Overflow or by Jayho
Published on 2009-10-21T10:19:55Z Indexed on 2010/03/18 20:01 UTC
Read the original article Hit count: 667

Filed under:

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>

© Stack Overflow or respective owner

Related posts about wpf