Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ItemsControl missing vertical scrollbar

I have the below ItemsControl which wraps items perfectly but it does not have a vertical scrollbar to see the wrapped items. How can I get the scrollbar to show?

    <ItemsControl x:Name="tStack" Grid.Column="0" Grid.Row="1"
                  ItemsSource="{Binding Shows.View}"
                  HorizontalAlignment="Stretch" VerticalAlignment="Stretch"
                  BorderThickness="0.5">
        <ItemsControl.ItemsPanel>
            <ItemsPanelTemplate>
                <WrapPanel Orientation="Horizontal" HorizontalAlignment="Left"
                           VerticalAlignment="Top"/>
            </ItemsPanelTemplate>
        </ItemsControl.ItemsPanel>
        <ItemsControl.ItemTemplate>
            <DataTemplate>
                <Viewbox HorizontalAlignment="Left"  Height="250">
                    <Controls1:MyShowsUserControl Padding="10"/>
                </Viewbox>
            </DataTemplate>
        </ItemsControl.ItemTemplate>
    </ItemsControl>
like image 406
touyets Avatar asked Aug 23 '13 08:08

touyets


2 Answers

Wrap your ItemsControl in a ScrollViewer control.

<ScrollViewer VerticalScrollBarVisibility="Auto">
  <ItemsControl ...
</ScrollViewer>

Remember to put the Grid.Column="0" Grid.Row="1" attributes in the ScrollViewer instead of in your ItemControl.

like image 193
Jonathan Avatar answered Nov 07 '22 08:11

Jonathan


ItemsControl by default does not wrap ItemsPresenter in ScrollViewer so you have to do it manually like so:

<ScrollViewer Grid.Column="0" Grid.Row="1">
   <ItemsControl x:Name="tStack" ... >
      <!-- .... -->
   </ItemsControl>
</ScrollViewer>
like image 29
dkozl Avatar answered Nov 07 '22 06:11

dkozl