How to make the last column in WPF datagrid take all the left space, always?

后端 未结 6 1541
执笔经年
执笔经年 2020-12-10 00:50

Standard WPF 4 Datagrid.

Let\' say I have datagrid 200 pixels wide, and 2 columns. I would like the columns take always entire space, meaning if the user resizes the

6条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-10 01:27

    You can set a column width to star on code. In your constructor, add:

        Loaded += (s, e) => dataGrid1.Columns[3].Width =
    new DataGridLength(1, DataGridLengthUnitType.Star);
    

提交回复
热议问题