将滚动条添加到ItemsControl [英] Add scrollbar to ItemsControl
本文介绍了将滚动条添加到ItemsControl的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在ItemsControl中添加了一个滚动条,但它仍然是不可见的。
I added a scroll bar to the ItemsControl, but it is still invisible.
<DockPanel>
<ScrollViewer VerticalScrollBarVisibility="Auto">
<ItemsControl Height="300" Name="icTodoList">
<ItemsControl.ItemTemplate>
<DataTemplate>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<TextBlock Text="{Binding StartTime, FallbackValue=' '}" Grid.Row="0"/>
<TextBlock Text="{Binding ConnectedTime, FallbackValue=' '}" Grid.Row="1"/>
<TextBlock Text="{Binding DisconnectedTime, FallbackValue=' '}" Grid.Row="2"/>
<TextBlock Text="{Binding DialResult, FallbackValue=' '}" Grid.Row="3"/>
</Grid>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</ScrollViewer>
</DockPanel>
推荐答案
最后我找到了解决方案。我必须将高度添加到DockPanel。
Finally I found the solution. I have to add Height to DockPanel.
<dockpanel Height="280"></dockpanel>
Richard的解决方案,即尝试删除高度=300
来自 ItemsControl
的属性不起作用。
Richard's solution, which was to try removing the Height="300"
attribute from the ItemsControl
doesn't work.
这篇关于将滚动条添加到ItemsControl的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文