I'll jump right to the chase:
I'm trying to create a silverlight application with a 3x3 grid. Here are the row definitions:
RowDefinition rowDef1 = new RowDefinition();
rowDef1.Height = new GridLength(5, GridUnitType.Pixel);
RowDefinition rowDef2 = new RowDefinition();
rowDef2.Height = new GridLength(1, GridUnitType.Star);
RowDefinition rowDef3 = new RowDefinition();
rowDef3.Height = new GridLength(75, GridUnitType.Pixel);
Now, I want the three columns to be like this:
ColumnDefinition colDef1 = new ColumnDefinition();
colDef1.Width = new GridLength(5, GridUnitType.Pixel);
ColumnDefinition colDef2 = new ColumnDefinition();
colDef2.Width = ??????? // equal to rowDef2.Height
ColumnDefinition colDef3 = new ColumnDefinition();
colDef3.Width = new GridLength(1, GridUnitType.Star);
How do I do this? I want to keep the middle element of the grid square, to be determined by the Row 2's height. I also want it to stay square after resizing, as if it's bound to Row 2's height.
Any help would be appreciated. I've searched the internet, but I can't really find anything to help. Also, if it's possible to do this in straight-up xaml, that'd be fine to. There's no real reason to do it in C#.
If it makes any difference, a grid is going to be the content of that middle grid location.
Thanks!
Loading
Benjamin SmallPosted Dec 31, 2009, 2:10 AM
First of all, I was able to do it all in xaml, so here it is.
By putting a simple 10x10 square image in behind my grid "Board", the image autofilled to the size I wanted, and kept its aspect ratio. The grid just filled in on top of it.
Dunno if anyone else has had problems like these, but if you have other ways (or less hacky ways) of solving this, please respond! Thanks.