2013-08-23 6 views
10

アイテムを完全にラップする以下のItemsControlがありますが、ラップされたアイテムが見えないように垂直スクロールバーがありません。スクロールバーを表示するにはどうすればよいですか?ItemsControlにスクロールバーがありません

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

答えて

19

ItemsControlはそうあなたがそうのようにそれを手動で行う必要がありScrollViewerItemsPresenterをラップしません。

< ScrollViewerのVerticalScrollBarVisibility = "自動">

ここにあなたのItemsControl

</ScrollViewerの>

+0

非常に奇妙な...私は前に20倍、それを試してみましたが、それはうまくいきませんでしたし、今ではありません... ありがとうございました! – touyets

+1

問題を見つけました。スクロールビューアの水平スクロールバーの表示の値を入力すると、スクロールバーが正しく動作しません – touyets

4

ScrollViewer制御であなたのItemsControlを包みます。

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

ScrollViewerのではなく、あなたのItemControlにGrid.Column="0" Grid.Row="1"属性を置くことを忘れないでください。

<ScrollViewer Grid.Column="0" Grid.Row="1"> 
    <ItemsControl x:Name="tStack" ... > 
     <!-- .... --> 
    </ItemsControl> 
</ScrollViewer> 
0

使用ScrollViewerのとプロパティ「VerticalScrollBarVisibility」真を設定します。デフォルトで