I have a WPF DataGrid and I am setting up columns manually in code behind. I am trying to set the column size to Auto with the following code:
customBoundColumn.Width = double.NaN;
But then at run-time I get the following error:
Value should not be infinity. Parameter name: value
I read in many places that double.NaN is what is used to set the column size to auto. What am I doing wrong?
P.S. customBoundColumn is an instance of DataGridBoundColumn
I believe you can simply use
DataGridLength.Auto
to set your width back toAuto