【问题标题】:Scrolling in horizontal ItemsControl在水平 ItemsControl 中滚动
【发布时间】:2013-08-07 19:53:41
【问题描述】:

如何添加一个滚动条,让我滚动浏览水平显示的项目?

   <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>

【问题讨论】:

    标签: wpf itemscontrol horizontal-scrolling


    【解决方案1】:
    <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>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多