wpfdatagridheadergridactualwidth

width of datagrid column is not as declared


I have a DataGrid with some columns set. In addition, there's Grid, whose column width I want to set (not bind) to the total of 3 DataGrid's columns width. What I'm trying to do is practically some "super headers" to the DataGrid columns.

the DataGrid columns are CheckBoxColumns with headers that are wider than the content of the cells themselves. When I query the dataGrid.Columns[0].ActualWidth I get (I think) the width of the checkboxes, and not the REAL width of the columns, which is the width of the header.

Please help !

using C# / WPF, visual studio 2013

All in code, please, no XAML


Solution

  • Solved it by using

    column.MinWidth = column.ActualWidth;
    column.Width = new DataGridLength(1, DataGridLengthUnitType.Star;