views:

103

answers:

2
<Window ... >
    <StackPanel>
        <Button>b1</Button>
        <Button>b2</Button>
    </StackPanel>
</Window>

how to make this look like this:

<Window ...>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition></RowDefinition>
            <RowDefinition></RowDefinition>
        </Grid.RowDefinitions>

        <Button>b1</Button>
        <Button Grid.Row="1">b2</Button>
    </Grid>
</Window>

without using a grid

+5  A: 

You could try that :

<Window ... >
    <UniformGrid Rows="2" Columns="1">
        <Button>b1</Button>
        <Button>b2</Button>
    </UniformGrid>
</Window>

Not as flexible as a full blown Grid, but simpler to use...

Thomas Levesque
Damn. It.
Will
Seconded. Can't believe i missed that.
Bubblewrap
Solved my problem, thanks!
Si
+2  A: 

Short answer: You can't.

Long answer: Write a custom Panel and override ArrangeOverride and MeasureOverride to simulate Grid behaviour.

StackPanel arranges each of its child elements to use minimal height (or minimal width if Orientation == Horizontal). StackPanel offers no properties to alter this behaviour. Grid on the other hand, unless indicated otherwise, will divide all available space evenly across each child (or rather row/column).

Bubblewrap