我有一个 ListBox,我用 WrapPanel 替换了它的 ItemsPanel.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?
将每个项目放置在单行单列(自动宽度)网格中,并为列命名.在 ListBox 上设置 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 - 所有项目应具有相同的宽度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!