Wpf 如何将groupBox中的几个按钮居中
我需要一种方法使WPF(C#)中的组框中的几个按钮居中(垂直和/或水平)Wpf 如何将groupBox中的几个按钮居中,wpf,xaml,button,alignment,Wpf,Xaml,Button,Alignment,我需要一种方法使WPF(C#)中的组框中的几个按钮居中(垂直和/或水平) 我使用了stackPanel,但我的按钮粘在一起:(您可以将所有按钮包装在网格或stackPanel中,并在其中设置对齐属性,如下所示 <Grid> <GroupBox Margin="10,10,10,10" FontSize="16" FontWeight="Bold" VerticalAlignment="Stretch" Background="L
我使用了stackPanel,但我的按钮粘在一起:(您可以将所有按钮包装在网格或stackPanel中,并在其中设置对齐属性,如下所示
<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>
Mindcracker网络
您的答案是正确的,但我的按钮粘在一起……我如何修复它?