9

I have a wrap panel displaying items but I cant get a scroll bar to work properly any idea's whats wrong ?

       <ScrollViewer>
        <ItemsControl Name="itemsControl">
            <ItemsControl.ItemsPanel>
                <ItemsPanelTemplate>
                    <WrapPanel ItemWidth="{Binding ElementName=sizeSlider, Path=Value}" 
                                   FlowDirection="LeftToRight"  Height="auto" Width="auto"
                                   HorizontalAlignment="Left" Name="wrapPanel1" 
                                   VerticalAlignment="Top"
                                   Margin="5"
                               >
                    </WrapPanel>
                </ItemsPanelTemplate>
            </ItemsControl.ItemsPanel>
        </ItemsControl>
    </ScrollViewer>
</StackPanel>

Kaya
  • 515
  • 2
  • 7
  • 19

1 Answers1

13

Your ScrollViewer is inside StackPanel which resizes to its content (either vertically or horizontally depending on its orientation). Place it either directly in a Window, a cell of a Grid, or a DockPanel for scroll bars to show up.

repka
  • 2,909
  • 23
  • 26
  • 1
    Thats the job nice one. Changed to grid and its fine. Thanks – Kaya Jun 02 '10 at 15:14
  • 1
    This helped me immensely. Hours spent troubleshooting--one thing to keep in mind is that if the WrapPanel is nested in a StackPanel 2 or 3 levels up, it will still cause this issue. That's what I was missing. – Garrison Neely Nov 07 '13 at 17:51