Для моего универсального приложения для Windows я пытаюсь центрировать StackPanel в сетке на странице, как на рисунке.Но когда я запускаю код ниже, три кнопки располагаются по центру внизу.В чем может быть проблема?
![enter image description here](https://i.stack.imgur.com/TDB7D.png)
MainPage.xaml:
<Page>
<Grid Background="WhiteSmoke">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid VerticalAlignment="Top">
<StackPanel Orientation="Horizontal" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="10 0">
<Button x:Name="BackButton" Height="50" Width="150" Background="{x:Null}" BorderBrush="White">
<StackPanel Orientation="Horizontal">
<Viewbox MaxHeight="50" MaxWidth="50">
<SymbolIcon Symbol="Back" Foreground="White"></SymbolIcon>
</Viewbox>
<TextBlock Foreground="White" VerticalAlignment="Center" Margin="10" FontSize="20" FontWeight="Bold">Back</TextBlock>
</StackPanel>
</Button>
</StackPanel>
<StackPanel Orientation="Horizontal" VerticalAlignment="Center" HorizontalAlignment="Center">
<Button Width="150" Height="50" Content="Page 1" FontSize="20" FontWeight="Bold"/>
<Button Width="150" Height="50" Content="Page 2" Foreground="#FFFFFF" FontSize="20" FontWeight="Bold"/>
<Button Width="150" Height="50" Content="Page 3" Foreground="#FFFFFF" FontSize="20" FontWeight="Bold"/>
</StackPanel>
<Grid Width="150" Height="5" Background="#FFFFFF" HorizontalAlignment="Center" Margin="240" />
</Grid>
<Frame
Grid.Row="1"
x:Name="Frame">
</Frame>
</Grid>
</Page>
Page1.xaml
<Page>
<Grid Background="WhiteSmoke">
<StackPanel VerticalAlignment="Center" HorizontalAlignment="Center">
<Button Height="150" Width="300" Margin="5" FontWeight="Bold" FontSize="20">
<StackPanel Orientation="Vertical">
<TextBlock Foreground="White" VerticalAlignment="Center" Margin="10" Padding="0">Page 1</TextBlock>
</StackPanel>
</Button>
<Button Height="150" Width="300" Margin="5" FontWeight="Bold" FontSize="20">
<StackPanel Orientation="Vertical">
<TextBlock Foreground="White" VerticalAlignment="Center" Margin="10" Padding="0">Page 2</TextBlock>
</StackPanel>
</Button>
<Button Height="150" Width="300" Margin="5" FontWeight="Bold" FontSize="20">
<StackPanel Orientation="Vertical">
<TextBlock Foreground="White" VerticalAlignment="Center" Margin="10" Padding="0">Page 3</TextBlock>
</StackPanel>
</Button>
</StackPanel>
</Grid>
</Page>
Редактировать : решение:
<Grid.RowDefinitions>
<RowDefinition Height="0.1*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
Удалить VerticalAlignment="Top"
в сетке