Stretching the items in a WPF ListView within a ViewBox

早过忘川 提交于 2019-11-30 04:46:43

Try setting the ItemContainerStyle for your ListView to something like:

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

You also might need to set <Viewbox Stretch="Fill"/>.

After this, I think you can remove all those other "HorizontalAlignment = Stretch" and "HorizontalContentAlignment = Stretch" setters in your code since it probably won't be necessary anymore.

Unexpectedly setting ScrollViewer.HorizontalScrollBarVisibility="Disabled" also worked for me:

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