VariableSizedWrapGrid和WrapGrid子级尺寸测量 [英] VariableSizedWrapGrid and WrapGrid children size measuring
问题描述
VariableSizedWrapGrid
和WrapGrid
的测量值都很奇怪-它们根据第一项测量所有子项.
Both VariableSizedWrapGrid
and WrapGrid
have strange measuring - they measure all children based on the first item.
因此,下面的XAML将剪切第三项.
Because of that, the following XAML will clip the third item.
<VariableSizedWrapGrid Orientation="Horizontal">
<Rectangle Width="50" Height="100" Margin="5" Fill="Blue" />
<Rectangle Width="50" Height="50" Margin="5" Fill="Red" />
<Rectangle Width="50" Height="150" Margin="5" Fill="Green" />
<Rectangle Width="50" Height="50" Margin="5" Fill="Red" />
<Rectangle Width="50" Height="100" Margin="5" Fill="Red" />
</VariableSizedWrapGrid>
好像VariableSizedWrapGrid
可以测量第一项,然后以所需的第一项大小测量其余的孩子.
Seems like VariableSizedWrapGrid
measures the first item and then the rest children are measured with desired size of the first one.
有什么解决方法吗?
推荐答案
您需要在每个矩形上使用附加属性VariableSizeWrapGrid.ColumnSpan和VariableSizeWrapGrid.RowSpan,并将ItemHeight和ItemWidth添加到VariableSizeWrapGrid:
You need to use the Attached Properties on each Rectangle VariableSizeWrapGrid.ColumnSpan and VariableSizeWrapGrid.RowSpan as well as add an ItemHeight and ItemWidth to the VariableSizeWrapGrid:
<VariableSizedWrapGrid Orientation="Horizontal" ItemHeight="50" ItemWidth="50">
<Rectangle
VariableSizedWrapGrid.ColumnSpan="1"
VariableSizedWrapGrid.RowSpan="2"
Width="50" Height="100" Margin="5" Fill="Blue" />
</VariableSizedWrapGrid>
这篇关于VariableSizedWrapGrid和WrapGrid子级尺寸测量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!