WPF在单独的网格之间共享列宽 [英] WPF share column width between separate grids
本文介绍了WPF在单独的网格之间共享列宽的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的WPF UserControl上有以下设置:
I have the following setup on my WPF UserControl:
<GroupBox>
<Grid>
...
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<GroupBox>
<Grid>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="..." />
我希望第二个ColumnDefinition的宽度与第一个ColumnDefinition的宽度相同,我想设置一个明确的宽度。相反,我希望两个网格列自动拉伸到网格列中最长内容的宽度!
I'd like the second ColumnDefinition to be the same width as the first ColumnDefinition, but I don't want to set an explicit width. Instead, I want both grids columns to automatically stretch to the width of the longest piece of content in either grid column!
这可能吗?
推荐答案
使用 SharedSizeGroup 。还请查看 IsSharedSizeScope 。
<GroupBox Grid.IsSharedSizeScope="True">
<Grid>
...
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" SharedSizeGroup="A" />
<GroupBox>
<Grid>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition SharedSizeGroup="A" />
请参阅 here 获取更多信息。
这篇关于WPF在单独的网格之间共享列宽的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文