Reputation: 2956
I need a way to make center several buttons in a group box in WPF(C#) (Vertically and/or horizontally).
I used stackPanel but my buttons stick together :(
Upvotes: 2
Views: 1196
Reputation: 9242
you can wrap all the button in grid or stackpanel and set there alignment properties like this..
<Grid>
<GroupBox Margin="10,10,10,10" FontSize="16" FontWeight="Bold" VerticalAlignment="Stretch"
Background="LightGray">
<GroupBox.Header>
Mindcracker Network
</GroupBox.Header>
<StackPanel VerticalAlignment="Center" HorizontalAlignment="Center">
<Button Content="hello1" Width="100" Margin="5" />
<Button Content="hello2" Width="100" Margin="5" />
<Button Content="hello3" Width="100" Margin="5" />
<Button Content="hello4" Width="100" Margin="5" />
</StackPanel>
</GroupBox>
</Grid>
Upvotes: 1