Is there an alternative to a WPF WrapPanel that wr

2019-08-04 16:56发布

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.

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.

Is there something I can do to make this happen?

标签: wpf wrappanel
2条回答
爷、活的狠高调
2楼-- · 2019-08-04 17:42

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

查看更多
该账号已被封号
3楼-- · 2019-08-04 17:42

here is a nice little article about the available layout panels in WPF. If one of these does not fit the bill, you might have to build your own custom panel, here is a decent demo.

查看更多
登录 后发表回答