组合扩展器和网格(可调整大小的扩展器)
我想要一个类似可调整大小的扩展器之类的东西。我的基本想法是这样的:
<Grid HorizontalAlignment="Left">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="2" />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Expander Grid.Column="0" ExpandDirection="Right">
...
</Expander>
<GridSplitter Grid.Column="1" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" />
...
</Grid>
问题是:如果我移动网格分离器并折叠扩展器,我会得到一个很大的空白区域。怎样才能让整根柱子倒塌呢?或者有另一种方法可以使扩展器“调整大小”
I would like to have something like a resizable Expander. My basic idea was something like this:
<Grid HorizontalAlignment="Left">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="2" />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Expander Grid.Column="0" ExpandDirection="Right">
...
</Expander>
<GridSplitter Grid.Column="1" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" />
...
</Grid>
The problem with this: if i move the grid splitter and collaps the expander i got a big empty area. How can make the entire column collapse? Or is there another way to make the expander "resizable"
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不确定您想要完成什么,但我认为从概念上讲,
Grid
应该是Expander.Content
的一部分,这对您有用吗?编辑:从第一列中删除了所有触发,因为它似乎没有必要。
另外:为了使其垂直工作,GridSplitter 的
HorizontalAlignment
必须设置为Stretch
,否则默认宽度为零(当然,特定于方向的其他所有内容也必须进行调整,但这很简单)Not sure what you are trying to accomplish but i think conceptually the
Grid
should be part of theExpander.Content
, would this work for you?Edit: Removed all the triggering from the first column as it seemed unnecessary.
Also: For this to work vertically the GridSplitter's
HorizontalAlignment
must be set toStretch
, otherwise it will have zero width by default (of course everything else that is orientation-specific must be adapted as well but that is straightforward)也许这将有助于解决您的“列折叠”问题
XAML:
添加
< /code>
Name="expGrid"
并添加Collapsed="Expander_Collapsed"
C# 代码:
Maybe this will help to solve your "column collapse" problem
XAML:
Add in
<Grid>
Name="expGrid"
and add in<Expander>
Collapsed="Expander_Collapsed"
C# Code: