Wpf ItemsControl缺少垂直滚动条
我有下面的Wpf ItemsControl缺少垂直滚动条,wpf,xaml,scroll,itemscontrol,Wpf,Xaml,Scroll,Itemscontrol,我有下面的ItemsControl,它完美地包装了项目,但没有垂直滚动条来查看包装的项目。如何让滚动条显示 <ItemsControl x:Name="tStack" Grid.Column="0" Grid.Row="1" ItemsSource="{Binding Shows.View}" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"
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>
将
项控件
包装在滚动查看器
控件中
<ScrollViewer VerticalScrollBarVisibility="Auto">
<ItemsControl ...
</ScrollViewer>
ItemsControl
默认情况下不会在ScrollViewer
中包装ItemsPresenter
,因此您必须像这样手动操作:
<ScrollViewer Grid.Column="0" Grid.Row="1">
<ItemsControl x:Name="tStack" ... >
<!-- .... -->
</ItemsControl>
</ScrollViewer>
使用ScrollViewer并将属性“VerticalScrollBarVisibility”设置为true
这是您的ItemsControl
非常奇怪。。。我以前试过20次,但没用,现在可以了。。。非常感谢。我解决了这个问题:如果我为scrollviewer的水平滚动条可见性输入了一个值,那么它就不能正常工作。如果不能正常工作,请添加scrollviewer父元素的高度。。。