user589195
user589195

Reputation: 4240

Setting the width of a grid layout in WPF

Im new to WPF and im annoyed I cant find this answer anywhere on the net.

I want to set the a gridlayout to have 3 columns. The first to be a quarter of the available width, the second to be half the available width and the third to be a quarter of the available width.

Is this possible and if so could someone provide me the Xaml?

Kind Regards

Ash

Upvotes: 0

Views: 442

Answers (2)

Jan K.
Jan K.

Reputation: 2582

<Grid x:Name="LayoutRoot">
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="0.25*"/>
        <ColumnDefinition Width="0.5*"/>
        <ColumnDefinition Width="0.25*"/>
    </Grid.ColumnDefinitions>
</Grid>

Upvotes: 3

Henk Holterman
Henk Holterman

Reputation: 273784

<Grid>
  <Grid.ColumnDefinitions>
     <ColumnDefinition Width="25*" />
     <ColumnDefinition Width="50*" />
     <ColumnDefinition Width="25*" />
  </Grid.ColumnDefinitions>
</Grid>

The * postfix means a weighted scale, you could also use 1*, 2*, 1*

Upvotes: 3

Related Questions