How do I align side by side in stackpanel?

Alvin picture Alvin · Sep 26, 2012 · Viewed 17.3k times · Source

How can I have the button align beside the ComboBox ? I am not able to drag the button to the side of the ComboBox using designer.

<Expander.Content>
    <StackPanel>
        <ComboBox Name="cbProd" Height="30" IsEditable="True" FontSize="15" />
        <Button Name="btnAdd" Content="add" Click="btnAddProduct_Click" />

Answer

SvenG picture SvenG · Sep 26, 2012

Just nest multiple layout containers like this:

<Expander.Content>
    <StackPanel Orientation="Vertical">
        <StackPanel Orientation="Horizontal">
            <ComboBox Name="cbProd" Height="30" IsEditable="True" FontSize="15" />
            <Button Name="btnAdd" Content="add" Click="btnAddProduct_Click" />
        </StackPanel>
        ... your other controls
    </StackPanel>
</Expander.Content>