[UWP][XAML] ListView child item not using full width

只愿长相守 提交于 2019-12-01 00:49:45
TekGiant

A friend helped me find this which means this question is now a duplicate since it's the same thing:

ListViewItem won't stretch to the width of a ListView

Just for clarity though, here was the takeaway code that solved my problem:

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

I was just attempting to get my ListView to stretch properly and found this answer. I'm using Visual Studio 2017 and working on a UWA (Universal Windows App) project.

I'm altering the default Grid element which was added by the project template and I couldn't get the ListView to stretch when it was added as a grid row / column.

I finally stumbled upon the XAML you can add directly to the ListView element:

HorizontalAlignment="Stretch" VerticalAlignment="Stretch"

It works great as you can see:

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