Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Scrolling in horizontal ItemsControl

How can I add a scrollbar that lets me scroll through horizontally displayed items?

   <ItemsControl ItemsSource="{Binding Data, ElementName=myWindows}">
        <ItemsControl.ItemsPanel>
            <ItemsPanelTemplate>
                <VirtualizingStackPanel Orientation="Horizontal">
                </VirtualizingStackPanel>
            </ItemsPanelTemplate>
        </ItemsControl.ItemsPanel>
        <ItemsControl.ItemContainerStyle>
            <Style TargetType="FrameworkElement" >
                <Setter Property="Margin" Value="10,0,10,0"></Setter>
            </Style>
        </ItemsControl.ItemContainerStyle>
    </ItemsControl>
like image 453
user1182735 Avatar asked Aug 06 '13 17:08

user1182735


1 Answers

<ItemsControl ItemsSource="{Binding Data, ElementName=myWindows}">
    <ItemsControl.ItemsPanel>
        <ItemsPanelTemplate>
            <VirtualizingStackPanel Orientation="Horizontal"/>
        </ItemsPanelTemplate>
    </ItemsControl.ItemsPanel>

   <!-- Add this Template -->
   <ItemsControl.Template>
       <ControlTemplate TargetType="ItemsControl">
           <ScrollViewer HorizontalScrollBarVisibility="Visible">
               <ItemsPresenter/>
           </ScrollViewer>
       </ControlTemplate>
   </ItemsControl.Template>

   <!-- ... Etc ... -->
</ItemsControl>
like image 101
Federico Berasategui Avatar answered Nov 07 '22 01:11

Federico Berasategui