How can I make a column in a listbox in WPF the same width for all items?

让人想犯罪 __ 提交于 2019-11-28 16:59:11

You can use the IsSharedSizeScope attached property. In your template definition, attach a "shared size group" to each column, like this:

<Grid.ColumnDefinitions>
    <ColumnDefinition SharedSizeGroup="col1" />
    <ColumnDefinition SharedSizeGroup="col2" />
</Grid.ColumnDefinitions>

... then define your ListBox as a shared size scope so it knows to size each "size group" the same way:

<ListBox Grid.IsSharedSizeScope="True">...</ListBox>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!