mikemuhl
mikemuhl

Reputation: 31

WPF Datagrid Column Width codebehind

I would like to replace the following xaml code:

<Custom:DataGridTextColumn Header=" " Width="*"/> in codebehind. This xaml code fills my header to the end with my style.

This is what I want to get:

|name | number | this area uses "mystyle" end of grid ->|

This is what I currently get:

|name | number | unstyled area! end of grid ->|

As you see, I would like to fill the unstyled area with my style, done this with xaml:

<Custom:DataGridTextColumn Header=" " Width="*"/>

Now I need it in cb please. ;)

Upvotes: 1

Views: 5544

Answers (2)

Yoiku
Yoiku

Reputation: 912

Ok I know this is kind of late but I just had the same problem and I solve the problem using DataGridLengthUnitType.Star (well actually I use Grid but it should be the same)

tc.Width = New DataGridLength(2.0, DataGridLengthUnitType.Star); // this will make the colum to be twice as big as the others

Upvotes: 3

kenwarner
kenwarner

Reputation: 29120

tc.Width = New DataGridLength(1.0, DataGridLengthUnitType.Auto);

Upvotes: 0

Related Questions