user2389722
user2389722

Reputation:

Centering several buttons WPF

I was writing C# code in winforms. In winForms using this menu (in the picture) I make center several buttons. But I can not find out any way to make center some elements horizontally in WPF.

enter image description here

Upvotes: 0

Views: 82

Answers (1)

keft
keft

Reputation: 366

Use the HorizontalAlignment property. For example:

<StackPanel Orientation="Horizontal" Height="50" HorizontalAlignment="Center">
    <Button Width="50" Margin="5"></Button>
    <Button Width="50" Margin="5"></Button>
    <Button Width="50" Margin="5"></Button>
    <Button Width="50" Margin="5"></Button>
</StackPanel>

Upvotes: 1

Related Questions