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:

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

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: , , , , , ,

2 Comments:

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...

@Anonymous
>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=http://community.bsu.edu/members/buy+online+Viagra.aspx]cheapest place to buy Viagra online no prescription[/url]

[url=http://ceklansi.ru/frazy-dlya-znakomstva-v-internete.php]фразы для знакомства в интернете[/url]
[url=http://ceklansi.ru/luchshiy-sayt-znakomstv-kazahstan.php]лучший сайт знакомств казахстан[/url]
[url=http://ceklansi.ru/shluhi-bishkek.php]шлюхи бишкек[/url]
[url=http://ceklansi.ru/intim-vakansii.php]интим вакансии[/url]
[url=http://ceklansi.ru/shluhi-vzroslye.php]шлюхи взрослые[/url]
[url=http://celuyou.ru/luchshie-prostitutki-saratova.php]лучшие проститутки саратова[/url]
[url=http://celuyou.ru/chastnye-obyavleniya-seks-znakomstv.php]частные объявления секс знакомств[/url]
[url=http://celuyou.ru/brateevo-intim.php]братеево интим[/url]
[url=http://celuyou.ru/znakomstva-komu-za-30-let.php]знакомства кому за 30 лет[/url]
[url=http://celuyou.ru/znakomstva-seks-ulan-ude.php]знакомства секс улан удэ[/url]
[url=http://deperovero.ru/poznakomlus-s-armyankoy.php]познакомлюсь с армянкой[/url]
[url=http://deperovero.ru/botanicheskiy-sad-intim.php]ботанический сад интим[/url]
[url=http://mx.deperovero.ru/novyy-arbat-prostitutki.php]новый арбат проститутки[/url]
[url=http://mx.deperovero.ru/prostitutki-kruglosutochno.php]проститутки круглосуточно[/url][url=http://rp.deperovero.ru/index.php]знакомства love planeta[/url]
[url=http://rp.deperovero.ru/intim-krasnogvardeyskaya.php]интим красногвардейская[/url]
[url=http://ss.deperovero.ru/prostitutki-zhenschiny-moskvy.php]проститутки женщины москвы[/url]
[url=http://ss.deperovero.ru/dating-ru-moskva-znakomstva.php]dating ru москва знакомства[/url][url=http://tt.deperovero.ru/index.php]екатеринбург интим знакомства доска[/url]
[url=http://tt.deperovero.ru/sayt-znakomstv-v-novorossiyske.php]сайт знакомств в новороссийске[/url]

 

Post a Comment

Subscribe to Post Comments [Atom]

<< Home