WPF WrapPanel是否有替代方法,可以包装一定数量的物品而不是高度的物品? [英] Is there an alternative to a WPF WrapPanel that wraps after a certain number of items, not a height?

查看:81
本文介绍了WPF WrapPanel是否有替代方法,可以包装一定数量的物品而不是高度的物品?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

通常,WPF WrapPanel(Orientation ="Vertical")将垂直堆叠项目(并垂直增长),直到父容器空间不足为止,然后将其换行"到下一列.

Normally a WPF WrapPanel (Orientation="Vertical") will stack items vertically (and grow vertically) until it runs out of space from the parent container, and then it will "wrap" to the next column.

我需要此功能,但我想对一列中的项目数添加硬限制.例如,如果我的身高为100,并且我有3个项目的高度为30像素,那么通常情况下,它们都可以包装而无需包装.但是,说我想强迫它在2之后换行.在那种情况下,我希望它只增长到60的高度,然后将第3项换行到第二列.

I want this functionality, but I want to add a hard limit to the number of items in a column. For instance, if my height is 100 and I have 3 items that are 30 pixels high, normally it could fit them all without wrapping. However, say I want to force it to wrap after 2. In that case, I want it to only grow to a height of 60, and wrap the 3rd item into the second column.

有什么我可以做的吗?

推荐答案

也许您可以使用 Rows 属性来定义垂直方向上的元素数量.

Maybe you can do it with the UniformGrid.
Use the Rows property to definie the amount of elements in vertical direction.

这篇关于WPF WrapPanel是否有替代方法,可以包装一定数量的物品而不是高度的物品?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆