WPF : Extend last column of ListView's GridView

前端 未结 7 728
北海茫月
北海茫月 2020-11-28 06:50

I have a ListView with a GridView with 3 columns. I want last column to take up remaining width of the ListView.

7条回答
  •  北海茫月
    2020-11-28 07:33

    I haven't seen a one-line/simple XAML only solution. Set a width that's appropriate for the design view, and then modify the width on window size change like this:

    Private Sub winMain_SizeChanged(sender As Object, e As SizeChangedEventArgs) Handles Me.SizeChanged
        TryCast(lvwDownload.View, GridView).Columns(3).Width = lvwDownload.ActualWidth - 340
    End Sub
    

    NOTE: This logic does not change/hover the width of a column when another is resized. It's great for filling a listview with the last column.

提交回复
热议问题