HorizontalChildrenAlignment="Stretch" 在 WrapGrid 中不起作用
HorizontalChildrenAlignment="Stretch" is not working in WrapGrid
<GridView ItemsSource="{Binding SomeSource}" >
<GridView.ItemsPanel>
<ItemsPanelTemplate>
<WrapGrid Orientation="Horizontal" HorizontalChildrenAlignment="Stretch"/>
</ItemsPanelTemplate>
</GridView.ItemsPanel>
<GridView.ItemTemplate>
<DataTemplate>
<Grid>
<ContentControl>
<!--hidden for simplicity-->
</ContentControl>
</Grid>
</DataTemplate>
</GridView.ItemTemplate>
</GridView>
WrapGrid中的HorizontalChildrenAlignment="Stretch"
没有效果?我怎样才能使网格项目以这样的方式对齐,即最左边的项目将保持在 WrapGrid 的左边界,而最右边的项目将保持在 WrapGrid 的右边界,并且额外的 space 均匀分布在网格项目之间?
目前grid items之间的space是grid items中指定的margin,最右边的items到WrapGrid的右边框有很大的间隙,如果剩下的space 不足以放入另一个网格项。理想情况下,我们希望额外的 space 均匀分布在网格项之间,而不是在最右边的网格项的右侧留下剩余的 space。
WrapGrid 没有这种开箱即用的动态功能。如果您有固定数量的商品要展示,您可以手动计算最佳边距。
其他选项是从 GridView 切换到 Grid,adapt the WPF code shown here. 但这也不是完全动态的解决方案,因为您需要定义每行显示的项目数。
我想你要找的是这个?
<WrapGrid Orientation="Horizontal" VerticalChildrenAlignment="Stretch"/>
不是水平的,而是 VerticalChildrenAlignment
。我必须补充一点,如果没有至少一件包裹的物品看起来确实很奇怪,因为水平调整大小会使物品 "jump"
<GridView ItemsSource="{Binding SomeSource}" >
<GridView.ItemsPanel>
<ItemsPanelTemplate>
<WrapGrid Orientation="Horizontal" HorizontalChildrenAlignment="Stretch"/>
</ItemsPanelTemplate>
</GridView.ItemsPanel>
<GridView.ItemTemplate>
<DataTemplate>
<Grid>
<ContentControl>
<!--hidden for simplicity-->
</ContentControl>
</Grid>
</DataTemplate>
</GridView.ItemTemplate>
</GridView>
WrapGrid中的HorizontalChildrenAlignment="Stretch"
没有效果?我怎样才能使网格项目以这样的方式对齐,即最左边的项目将保持在 WrapGrid 的左边界,而最右边的项目将保持在 WrapGrid 的右边界,并且额外的 space 均匀分布在网格项目之间?
目前grid items之间的space是grid items中指定的margin,最右边的items到WrapGrid的右边框有很大的间隙,如果剩下的space 不足以放入另一个网格项。理想情况下,我们希望额外的 space 均匀分布在网格项之间,而不是在最右边的网格项的右侧留下剩余的 space。
WrapGrid 没有这种开箱即用的动态功能。如果您有固定数量的商品要展示,您可以手动计算最佳边距。
其他选项是从 GridView 切换到 Grid,adapt the WPF code shown here. 但这也不是完全动态的解决方案,因为您需要定义每行显示的项目数。
我想你要找的是这个?
<WrapGrid Orientation="Horizontal" VerticalChildrenAlignment="Stretch"/>
不是水平的,而是 VerticalChildrenAlignment
。我必须补充一点,如果没有至少一件包裹的物品看起来确实很奇怪,因为水平调整大小会使物品 "jump"