WPF WrapPanel - all items should have the same width(WPF WrapPanel - 所有项目应具有相同的宽度)
问题描述
我有一个 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 - 所有项目应具有相同的宽度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:WPF WrapPanel - 所有项目应具有相同的宽度


- 良好实践:如何重用 .csproj 和 .sln 文件来为 CI 创建 2022-01-01
- Web Api 中的 Swagger .netcore 3.1,使用 swagger UI 设置日期时间格式 2022-01-01
- 输入按键事件处理程序 2022-01-01
- 如何用自己压缩一个 IEnumerable 2022-01-01
- 带有服务/守护程序应用程序的 Microsoft Graph CSharp SDK 和 OneDrive for Business - 配额方面返回 null 2022-01-01
- C# 中多线程网络服务器的模式 2022-01-01
- C#MongoDB使用Builders查找派生对象 2022-09-04
- WebMatrix WebSecurity PasswordSalt 2022-01-01
- MoreLinq maxBy vs LINQ max + where 2022-01-01
- 在哪里可以找到使用中的C#/XML文档注释的好例子? 2022-01-01