Aymeric
Aymeric

Reputation: 1324

How to get a specific Grid's Row or Column Width and Height value?

In my application I have a Grid that is divided in two columns:

 instance_room[room_guid].Room_grid.ColumnDefinitions.Add(new ColumnDefinition());
 instance_room[room_guid].Room_grid.ColumnDefinitions.Add(new ColumnDefinition() { MinWidth = 130, MaxWidth = 250 });

To which I add I add a Canvas in the first one:

 Grid.SetColumn(instance_room[room_guid].Room_canvas, 0);

I would like after that to be able to retrieve, in code-behind, the width or height of my Column(0).

I tried many things, but none has worked properly, any answers?

Thank you, Ephismen.

[EDIT] Since I have children into my grid(0) I accessed it's width and height with:

temp_roomlist[tag[0]].Room_canvas.Height = (double)temp_roomlist[tag[0]].Room_canvas.Parent.GetValue(Grid.ActualHeightProperty);

Thanks for the answers!

Upvotes: 0

Views: 1036

Answers (2)

KeithMahoney
KeithMahoney

Reputation: 3343

Can you use Room_grid.ColumnDefinitions[0].Width?

Upvotes: 0

Jacob Nelson
Jacob Nelson

Reputation: 3006

Cells/Columns/Rows do not have heights and/or widths unless you manually set their widths and/or heights.

Upvotes: 1

Related Questions