Sha*_*que 3 wpf scroll listbox gridsplitter
我有一个有7行的网格.行0是一组2个按钮行1是列表框的对象行2是一组3个按钮行3是一组2个按钮行4是我的GridSplitter所在的行第5行是一组2个按钮第6行是一个ListBox对象
我希望GridSplitter上下滑动,调整两个ListBox中的每一个的大小.我现在已经把它放在自己的行中了,当我滑动它时,它会在它到达第4行(它自己的行)的顶部时冻结,并且只是在它向下扩展第4行时创建空白区域.
我只需要拆分器上下滑动并调整每个ListBox的大小.目前,如果ListBoxes的视图太大,那么它们会有垂直滚动条.
有任何想法吗?
这是一些XAML,它显示了GridSplitter如你所描述的如何使用a :
<Grid VerticalAlignment="Stretch">
<Grid.RowDefinitions>
<RowDefinition Height="10" />
<RowDefinition Height="10" />
<RowDefinition Height="10" />
<RowDefinition Height="10" />
<RowDefinition Height="10" />
<RowDefinition Height="10" />
<RowDefinition Height="*" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Rectangle Grid.Row="0" Fill="Red" />
<Rectangle Grid.Row="1" Fill="Orange" />
<Rectangle Grid.Row="2" Fill="Yellow" />
<Rectangle Grid.Row="3" Fill="Green" />
<Rectangle Grid.Row="4" Fill="Blue" />
<Rectangle Grid.Row="5" Fill="LightBlue" />
<ListBox Grid.Row="6" Background="Indigo">
<ListBoxItem>Hello</ListBoxItem>
<ListBoxItem>World</ListBoxItem>
</ListBox>
<GridSplitter Grid.Row="7" Height="5" Background="Gray"
VerticalAlignment="Top" HorizontalAlignment="Stretch" />
<ListBox Grid.Row="7" Background="Violet" Margin="0,5,0,0">
<ListBoxItem>Hello</ListBoxItem>
<ListBoxItem>World</ListBoxItem>
</ListBox>
</Grid>
Run Code Online (Sandbox Code Playgroud)
避免将GridSplitter放在它自己的行中.将其放在现有行中,并将其对齐设置为顶部(或底部,如果在上部单元格中),水平拉伸.注意我是如何将它的高度设置为5,然后给第二个ListBox的上边距为5,这样两个元素都不会隐藏另一个元素的任何部分.
希望有所帮助.
| 归档时间: |
|
| 查看次数: |
8102 次 |
| 最近记录: |