peter
peter

Reputation: 13

WPF How to bind GridView column width in code?

I need to bind width property of the GridView column that is created dynamically in code.

Since GridViewColumn object has no SetBinding method, how should I do this?

Thanks in advance.

Upvotes: 1

Views: 2519

Answers (3)

odyth
odyth

Reputation: 4336

GridViewColumn gvc = new GridViewColumn();
gvc.Header = "Value";
Binding b = new Binding();
b.XPath = "./Data/@Value";
gvc.DisplayMemberBinding = b;
GridView.Columns.Add(gvc);

Upvotes: 0

Janie
Janie

Reputation: 1933

You could do a SetValue within the event handler responsible for changing the width state of the column and update that way.

Upvotes: 0

Related Questions