I was wondering how can I define the column widths for a silverlight/WPF grid with percentages like we use to define in html tables. This msdn document was quite helpful. Let me paste the important part here. The width attribute can take three type of values:
- doubleValue: The column’s width, expressed as a floating-point value for a pixel count. Typically this is given as an integer, although interpolation of floating-point values is supported by grid layout.
- starSizing: A convention by which you can size rows or columns to take remaining available space in the Grid. A starSizing always includes the literal character *, and optionally precedes the * with an integer value that specifies what share of available space should be given as a weighted factor versus other possible star sizings (for example, 3*).
- Auto: The column’s width, described by the literal Auto.
So this is how we can define a grid with two equally divided rows and three columns divided in the ratio 1:2:3:
The .5* in the row height can be changed to any value but both values must be same to make sure the rows are divided evenly.