Is there a way to combine rows within a specific column? Hence to get something like this (I am currently using rowspan on a control i.e. Image but is there a better way?)
--------------------
| |--------|
| |--------|
| |--------|
| |--------|
| |--------|
--------------------
I am using this code basically
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="28" />
<RowDefinition Height="28" />
<RowDefinition Height="28" />
<RowDefinition Height="*" />
<RowDefinition Height="28" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="124" />
<ColumnDefinition Width="246*" />
</Grid.ColumnDefinitions>
Which gives me something like this (notice the rows also appear in column 0)
--------------------
|---------|--------|
|---------|--------|
|---------|--------|
|---------|--------|
|---------|--------|
--------------------
Now i can get around this for example if i want to place a image i can use RowSpan, but is it not possible to design a column with no rows and the other columns having rows?
This is not possible with the Grid
control. Rows pass through all columns, and columns pass through all rows. As you've found, the RowSpan
and ColumnSpan
allow you to have a control span multiple rows or columns respectively.
One other potential workaround is to host one Grid
within another:
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Image/>
<Grid Grid.Column="1">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
</Grid>
</Grid>
How about something like this:
<StackPanel Orientation="Horizontal">
<Grid Height="100" Width="50"></Grid>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="*" />
<RowDefinition Height="*" />
<RowDefinition Height="*" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="150" />
</Grid.ColumnDefinitions>
</Grid>
</StackPanel>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With