简体   繁体   English

如何拉伸ListView项目宽度以填充父容器?

[英]How to stretch ListView items width to fill parent container?

How to stretch listview items width to fill parent container? 如何拉伸listview项目宽度以填充父容器?

The default behaviour seems to be squishing everything as narrow as possible. 默认行为似乎是尽可能地缩小所有内容。

The problem is not with the child item but with the itemcontainer which has a HorizontalAlignment=Left hidden somewhere deep inside the framework code. 问题不在于子项,而在于itemcontainer,其中Horizo​​ntalAlignment = Left隐藏在框架代码的深处。 Only after fixing this will you get the behaviour one would expect to be there by default. 只有在修复此项后,您才能获得默认情况下会出现的行为。 截图显示问题和解决方案之前和之后

<ListView.ItemContainerStyle>
  <Style TargetType="ListViewItem">
    <Setter Property="HorizontalContentAlignment" Value="Stretch" />
  </Style>
</ListView.ItemContainerStyle>

<GroupStyle.HeaderContainerStyle >
  <Style TargetType="ListViewHeaderItem">
    <Setter Property="HorizontalContentAlignment" Value="Stretch" />
  </Style>
</GroupStyle.HeaderContainerStyle>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM