具有自动高度的网格行中的列表框。滚动条不起作用 [英] ListBox in Grid Row with Auto height. Scrollbar is not working
问题描述
我有以下网格:
< Grid>
< Grid.RowDefinitions>
< RowDefinition Height =Auto/>
< RowDefinition Height =Auto/>
< RowDefinition Height =*/>
< RowDefinition Height =Auto/>
< /Grid.RowDefinitions>
< Border Height =50Background =GainsboroGrid.Row =0/>
< Border Background =AliceBlueGrid.Row =1>
< ListBox ScrollViewer.VerticalScrollBarVisibility =AutoItemsSource =asdasdfasdf3dfasdf/>
< / Border>
< Border Height =60Background =AquamarineGrid.Row =3/>
< / Grid>
为什么ListBox的scrollviewer未启用?最后一个边框被推出窗口。如果我将Grid.Row 2 Height设置为* star - 它很好地工作。是否有可能在自动高度网格行中使用滚动查看器的列表框?
$ c>可以根据需要调整控件的大小。因此,您的 ListBox
会自行调整大小以显示其所有内容,滚动条将永远不会显示。
*
使您的控件可以使用可用的大小,并且不会超出此范围。
您需要做的是为 ListBox 定义
MaxHeight
code>或在 RowDefinition
中使用 *
作为高度。
I have the following grid:
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Border Height="50" Background="Gainsboro" Grid.Row="0"/>
<Border Background="AliceBlue" Grid.Row="1">
<ListBox ScrollViewer.VerticalScrollBarVisibility="Auto" ItemsSource="asdasdfasdf3dfasdf"/>
</Border>
<Border Height="60" Background="Aquamarine" Grid.Row="3"/>
</Grid>
Why ListBox's scrollviewer is not enabled? Last border is pushed out of a window. If i set the Grid.Row 2 Height to * star - it works nicely. Is it possible to have listbox with scrollviewer in auto height grid row?
Auto
makes your control resize as it needs. Therefore your ListBox
will resize itself to show all its content and the scroll bar will never been shown.
*
makes your control to take the available size, and it does not grow beyond that.
What you need to do is either define the MaxHeight
property for the ListBox
or use *
as height in RowDefinition
.
这篇关于具有自动高度的网格行中的列表框。滚动条不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!