TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Benjamin Small
NA
3
0
How to lock aspect ratio for Grid element (make it square)
Dec 27 2009 4:51 PM
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!
Reply
Answers (
1
)
Global/Public Variables in Multithreading
export to csv file