Wednesday, March 7, 2012

WPF: Define Percentage In Column Widths

To define the percentage in the width, in the example below, instead of 70%, replace it with .7*.
<Grid>
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width=".7*" />
        <ColumnDefinition Width=".3*" />
    </Grid.ColumnDefinitions>
    <Grid.RowDefinitions>
        <RowDefinition Height="*" />
    </Grid.RowDefinitions>
    <TextBlock Grid.Column="0">70% width</TextBlock>
    <TextBlock Grid.Column="1">30% width</TextBlock>
</Grid>