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

后端 未结 2 1043
日久生厌
日久生厌 2021-01-06 03:30

I\'m trying to display a list of bound items. I\'ve customized the datatemplate to be a grid and I want the right column (that has a fixed width) to stick to the right side

相关标签:
2条回答
  • 2021-01-06 03:36

    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:

    0 讨论(0)
  • 2021-01-06 04:00

    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>
    
    0 讨论(0)
提交回复
热议问题