c# wpf row definition

1.4k Views Asked by At

I need a help about some code. how can i split a row into two columns.My code is under this text.

    <Grid.RowDefinitions>
        <RowDefinition Height="30"/>
        <RowDefinition Height="50"/>
        <RowDefinition Height="50"/>
        <RowDefinition Height="50"/>
        <RowDefinition Height="30"/>
        <RowDefinition Height="*"/>
    </Grid.RowDefinitions>
    <StackPanel Grid.Row="0">

so how can i split row 0 into two columns, thanks

2

There are 2 best solutions below

0
On BEST ANSWER

You just need to add

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

and then to put your StackPanel in the first row and the first column

<StackPanel Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2">
</StackPanel >

and modify the span if you want a control to span over multiple cells

0
On

Put a Grid with 2 columns inside row 0 of the main Grid. Or, declare your grid as having 2 columns and set whatever you place in every row except row 0 with ColumnSpan = 2.