网格分割器未显示
我是 WPF 新手。我这样声明我的 Grid:
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"></ColumnDefinition>
<ColumnDefinition Width="5"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<Grid Grid.Column="0">
<Grid.RowDefinitions>
<RowDefinition Height="*"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
</Grid.RowDefinitions>
</Grid>
我基本上希望宽度为 5 的第三列成为 GridSplitter,并且可以调整左右列的大小。所以我有分割器的代码:
<GridSplitter Grid.Column="1" Grid.RowSpan="3" ResizeDirection="Columns" Height="Auto"
VerticalAlignment="Stretch" HorizontalAlignment="Center"
Margin="0" Background="Black"/>
我在列中没有看到 GridSplitter
。我设置对了吗?谢谢。
I am new to WPF. I declared my Grid
as so:
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"></ColumnDefinition>
<ColumnDefinition Width="5"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<Grid Grid.Column="0">
<Grid.RowDefinitions>
<RowDefinition Height="*"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
</Grid.RowDefinitions>
</Grid>
I basically want that 3rd column of width 5 to be the GridSplitter
and to be resizeable for the left and right columns. So I have this code for the splitter:
<GridSplitter Grid.Column="1" Grid.RowSpan="3" ResizeDirection="Columns" Height="Auto"
VerticalAlignment="Stretch" HorizontalAlignment="Center"
Margin="0" Background="Black"/>
I do not see the GridSplitter
in the column. Did I set it up right? Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您将 GridSplitter 置于其列的中心,但没有定义宽度。所以你实际上是以零宽度将其居中。看起来您也有两个网格,而您需要一个。
似乎您想要这样的东西:
如果您需要嵌套网格,那么您可能需要复制列定义。
You have the GridSplitter centering in it's column, but it has no width defined. So you are effectively centering it with a width of zero. It also looks like you have two Grids, where you'd need one.
Seems like you want something like this:
If you need the nested Grid, then you may need to duplicate the Column definitions.
我刚刚运行了这个 XAML,它工作正常
您确定要将三行放入第 0 列吗?因为这没有多大意义
你正在这样做,
但显然第一列没有三行,我认为你错误地将其放置在第 0 列中。
我认为你想要做的是我编写的第一个 XAML
I just ran this XAML and it works fine
Are you sure you want to put three rows inside 0th column? because it doesn't make much sense
And you are doing this
But apparently first column don't have three rows which I think you have mistakenly placed in column 0.
I think what you want to do is first XAML I wrote