How to make a column's width 50% of the grid's width?

hello,

is this possible. Something like <columnDefinition width="0.5"> or <columnDefinition width="50%"> doesn't seem to work.

thanks in advance
Kimme


Answer this question

How to make a column's width 50% of the grid's width?

  • dotnetdev

    If you really want one column to be 1/2 the width even with other columns present, you can also use a value converter. By binding the width of the grid to the width of the column, and using a value converter to apply the 1/2 you can control the column width. You can also do any other math you need in the value converter. You can pass a parameter to the value converter as well, which would allow you to do any proportion.

  • Some Developers

    You can use 2 columns with <columnDefinition width="*"> and each of them will have 50% of the grid's width.



  • johnrballard

    You can also just say

    <ColumnDefinition Width=".5*" /> for 50%.

    Making two columns is easy if you're going for 50%...but for complicated values, like 17% and 83% you can do the following.

    <ColumnDefinition Width=".17*" />

    <ColumnDefinition Width=".83*" />


  • Paul Deen

    And you should also check into the following syntax:

    <ColumnDefinition Width="100"/>
    <ColumnDefinition Width="0.5*"/>
    <ColumnDefinition Width="0.5*"/>

    Which will lock the first column to 100 pixels and spread out the following two columns evenly... Very cool...


  • How to make a column's width 50% of the grid's width?