我正在尝试使用以下方法将多个网格嵌入到另一个网格中ItemsControl
并使所有子网格共享相同的行高:
<Grid>
<ItemsControl ItemsSource="{Binding ControlItems}">
<ItemsControl.ItemsPanel>
<CustomPanel></CustomPanel>
</ItemsControl.ItemsPanel>
<ItemsControl.DataTemplate>
<CustomControl/>
</ItemsControl.DataTemplate>
</ItemsControl>
</Grid>
其中 CustomControl 实际上是一个自定义的 Grid,如下所示:
<Grid>
<Grid.RowDefinitions>
<RowDefinition SharedSizeGroup="CustomControlGroup" />
<RowDefinition SharedSizeGroup="CustomControlGroup" />
<Grid.RowDefinitions>
</Grid>
但是子网格中的行不共享相同的大小?
那么按照这个article http://wpftutorial.net/GridLayout.html#sharedsize。您必须设置IsSharedSizeScope
父控件中的属性True
。所以可能它应该看起来更像:
<ItemsControl Grid.IsSharedSizeScope="True">
<Grid>
<Grid.RowDefinitions>
<RowDefinition SharedSizeGroup="CustomControlGroup" />
<RowDefinition SharedSizeGroup="CustomControlGroup" />
<Grid.RowDefinitions>
</Grid>
</ItemsControl>
Here http://msdn.microsoft.com/en-us/library/ms751905.aspx是来自 MSDN 的另一个例子。恕我直言,第一篇文章更容易理解。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)