WPF WrapPanel中 - 所有项目应具有相同的宽度 [英] WPF WrapPanel - all items should have the same width
问题描述
我有一个列表框的ItemsPanel我替换一个WrapPanel中。 该WrapPanel中现在拥有数据绑定ListboxItems。每个项目中有一个可变大小的文字,给每个项目不同的宽度。 但是,我想的宽度是恒定的,使得所有项具有相同的宽度具有最长文本的项目。 这可能吗?
I have a ListBox whose ItemsPanel I have replaces with a WrapPanel. The WrapPanel now hosts the databound ListboxItems. Each item has a variable sized text in it, giving each item a different width. However, I want the width to be constant so that all items have the same width as the item with the longest text. Is that possible?
推荐答案
将每个项目的单排,单柱(自动宽度)网格,并命名列。在列表框设置Grid.IsSharedSizeScope,所有电网将具有相同的宽度。
Place each item in a single-row, single-column (auto width) grid, and name the column. Set Grid.IsSharedSizeScope on the ListBox and all grids will have the same width.
这篇关于WPF WrapPanel中 - 所有项目应具有相同的宽度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!