Thursday, July 24, 2008

Assign percentage width to a column in silverlight grid

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:

<RowDefinition Height=".5*"></RowDefinition>
<RowDefinition Height=".5*"></RowDefinition>
<ColumnDefinition Width="1*"></ColumnDefinition>
<ColumnDefinition Width="2*"></ColumnDefinition>
<ColumnDefinition Width="3*"></ColumnDefinition>

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.

Labels: , , , , , ,


At August 5, 2008 at 7:05 PM , Anonymous Anonymous said...

Congrats Mehroz for Silverlight 2 prize!!!
For dividing row into equal halves, you dont need to mention height, its by default divided into 50%

At August 5, 2008 at 10:53 PM , Blogger Syed Mehroz Alam said...

>Congrats Mehroz for Silverlight 2 prize!!!
Thank you.

>For dividing row into equal halves, you don't need to mention height, its by default divided into 50%
Absolutely, if we don't give the height/width attribute for a row/column, we get a "*" by default.

At December 2, 2009 at 6:49 PM , Anonymous Anonymous said...

[url=]cheapest place to buy Viagra online no prescription[/url]

[url=]фразы для знакомства в интернете[/url]
[url=]лучший сайт знакомств казахстан[/url]
[url=]шлюхи бишкек[/url]
[url=]интим вакансии[/url]
[url=]шлюхи взрослые[/url]
[url=]лучшие проститутки саратова[/url]
[url=]частные объявления секс знакомств[/url]
[url=]братеево интим[/url]
[url=]знакомства кому за 30 лет[/url]
[url=]знакомства секс улан удэ[/url]
[url=]познакомлюсь с армянкой[/url]
[url=]ботанический сад интим[/url]
[url=]новый арбат проститутки[/url]
[url=]проститутки круглосуточно[/url][url=]знакомства love planeta[/url]
[url=]интим красногвардейская[/url]
[url=]проститутки женщины москвы[/url]
[url=]dating ru москва знакомства[/url][url=]екатеринбург интим знакомства доска[/url]
[url=]сайт знакомств в новороссийске[/url]


Post a Comment

Subscribe to Post Comments [Atom]

<< Home