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

Thursday, July 10, 2008

Transposing an excel sheet

Today, I came across a problem where I needed to transpose data inside an excel sheet. After some Google search, I was able to achieve it like this:

  • Select the data you wish to transform
  • Copy it to clipboard
  • In a new worksheet (or file), right click and select "Paste Special"
  • Check the "Transpose" checkbox and hit Ok.

Thats all......Now you use "Filters" on the columns (that were previously rows).

Labels: , , ,

Wednesday, July 09, 2008

Coming soon

My blog will be re-active soon. Stay tuned for new posts.

Thank you.