3
votes

I have a DataGrid with a custom theme. Right now, if I resize a column and make it wider, it tries to squeeze other columns to make space for this column.

Instead, is it possible to increase the width of the entire DataGrid with the increase in width of a column. It's OK if it shows a horizontal scrollbar at the bottom.

EDIT: Just to clarify, each column has a MinWidth set to it. So if the overall width > window width, I see a scrollbar. But in cases where I have a datagrid <= window width, and I expand one of its column, the width of the datagrid should theoritically increase at the point when the other columns have shrunk to their MinWidths. At that point, instead of letting the DataGrid grow in width, it doesn't let me expand the column any further. Instead, I want the DataGrid to expand and accommodate the increased space.

3

3 Answers

2
votes

It sounds like one of your columns has a Width="*", which means that column is assigned to all remaining space and grows/shrinks as needed instead of letting the DataGrid grow/shrink as requested and showing it's HorizontalScrollBar.

0
votes

The datagrid's default behaviour is the one you need! If your Datagrid is not showing a horizontal scrollbar maybe because it's contained in a control that's constraining its width. Try to put it inside a Grid, and be sure that you haven't set the 'Width' property of any control (including the Window) that is containing it.

0
votes

that's what column's MinWidth is designed for. Just set it for the columns, which you don't want to shrink. to limit the max width of the grid use the ScrollViewer:)