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

时间:2014-06-25 10:33:56

标签: listview winrt-xaml windows-phone-8.1 fill-parent

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

默认行为似乎是尽可能缩小所有内容。

1 个答案:

答案 0 :(得分:25)

问题不在于子项,而在于itemcontainer,其中Horizo​​ntalAlignment = Left隐藏在框架代码的深处。只有在修复此项后,您才能获得默认情况下会出现的行为。 Before and after screenshots showing both the problem and the solution

<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>