Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
625
Column widths not auto-sizing correctly when header label wraps
posted

I'm using XamDataGrid from version 10.3.20103.1003 of the WPF control set. In my grid, I need column headers to be 12pt and bold with text wrapping. The following code accomplishes this for me:

grid.FieldLayoutSettings.HeaderLabelAreaStyle = new Style(typeof(HeaderLabelArea));
grid.FieldLayoutSettings.HeaderLabelAreaStyle.Setters.Add(new Setter(HeaderLabelArea.FontSizeProperty, 12d));
grid.FieldLayoutSettings.HeaderLabelAreaStyle.Setters.Add(new Setter(HeaderLabelArea.FontWeightProperty, FontWeights.Bold));
grid.FieldSettings.LabelTextWrapping = TextWrapping.WrapWithOverflow;

Additionally, I need the grid columns to auto-size base on the header label and cell values. The following code accomplishes this:

grid.FieldSettings.AutoSizeScope = FieldAutoSizeScope.RecordsInView;
grid.FieldSettings.AutoSizeOptions = FieldAutoSizeOptions.DataCells | FieldAutoSizeOptions.Label;


The problem I'm having is that when a column header label wraps, the column doesn't resize to the smallest possible width based on the wrapped header label and cell value.  When the column header label does on wrap, the auto-size feature works as expected.

Is this a known issue and is there a workaround?

Thanks,
Paul