See the question and my original answer on StackOverflow

Depending on your setting, you can achieve that simply using StackPanel's alignments. For example this XAML

<Window Width="350" Height="350" ...> 
    <Grid>
        <StackPanel
            Background="Green">
            <Border
                Width="100"
                Height="100"
                Background="Blue" />
            <Border
                Width="100"
                Height="100"
                Background="Red" />
        </StackPanel>
    </Grid>
</Window>

Will create this (the panel stretches to parent's size):

enter image description here

And this panel:

<Window Width="350" Height="350" ...> 
    <Grid>
        <StackPanel
            HorizontalAlignment="Center"
            VerticalAlignment="Center"
            Background="Green">
            <Border
                Width="100"
                Height="100"
                Background="Blue" />
            <Border
                Width="100"
                Height="100"
                Background="Red" />
        </StackPanel>
    </Grid>
</Window>

Will create this (sized to the two contained Borders):

enter image description here