WPF-datagrid Width="SizeToHeader" OR "SizeToCells"

Jun 19, 2009 at 4:28 PM

Hello,
I have a datagrid and I want to columns to size so I can see the whole content: Width="SizeToCells"
Problem is that I have an empty comboBox in wich the user still has to make a selection.
As long as the column is empty, the size of the column is very small and almost invisible for the user.

If I set:  Width="SizeToheader" the size is to small if the users makes a selection.

So what I want is: make the size of the column "SizeToCells", but if this is smaller than the width of the header I want it to be ="SizeToheader" .

Is this possible?

Thanks in advance,

Jun 19, 2009 at 8:20 PM

Doesn't it automatically resize? Try without and width specifier.

Aug 26, 2010 at 2:13 AM

Just set Width to "SizeToCells" and use the MinWidth property to specify the width that makes the header readable (use a split between design and xaml to see what the vales should be when you edit the numbers). It's not verry user friendly to set up, but it does exactly what you want it to do.