Trigger the "OnCellSeperatorDoubleClick" in a WPF DataGridView?
I was just wondering if there was a way to trigger the same event that happens when you double click the line between two columns in a DGV. I would like 2 of my columns to, after setting the width of all of the columns, auto resize to the width of their text to take up the extra space.
Is that possible?
If you mean the WPF 'DataGrid', in .NET 4.0, from a quick look at PresentationFramework in ILSpy, it looks like all double clicking on the resize gripper does is sets the width of the column to DataGridLength.Auto.
So you could do something like the following to get the same result as double clicking:
someGrid.Columns.Width = DataGridLength.Auto;
If you want the column to fill available space (using the wpf star weighting) then you could use something like:
someGrid.Columns.Width = new DataGridLength(1, DataGridLengthUnitType.Star);