C# 一页中的所有导航

C# 一页中的所有导航,c#,xaml,windows-store-apps,C#,Xaml,Windows Store Apps,我是使用XAML和C#的Windows 8应用程序的新手。 我希望所有的导航都在一个页面上,我在主页上创建了一个按钮,然后创建了第二个页面。当用户单击主页面上的按钮时,第二页必须显示在主页面上。 我该怎么做 主页xaml: <Button Content="click" FontSize="60" Margin="191,283,0,382" Height="103" Click="Button_Click" ></Button> 第1页: <TextBlock

我是使用XAML和C#的Windows 8应用程序的新手。
我希望所有的导航都在一个页面上,我在主页上创建了一个按钮,然后创建了第二个页面。当用户单击主页面上的按钮时,第二页必须显示在主页面上。
我该怎么做

主页xaml:

<Button Content="click" FontSize="60" Margin="191,283,0,382" Height="103" 
Click="Button_Click" ></Button>
第1页:

<TextBlock FontSize="59" SelectionChanged="TextBlock_SelectionChanged">
    hi  2nd page is open
</TextBlock>

你好,第2页已打开

当用户单击按钮时,第二页应显示在主页面中。

您必须在主页面内使用
Frame
。试试这个

MainPage.xaml

<Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush}">
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="227*"/>
        <ColumnDefinition Width="1139*"/>
    </Grid.ColumnDefinitions>
    <Button Name="firstPageButton" Content="First Page" Grid.Column="0" HorizontalAlignment="Left" VerticalAlignment="Top" Height="53" Width="227" Click="firstPageButton_Click"/>

    <Frame Name="rootFrame" Content="" HorizontalAlignment="Left" VerticalAlignment="Top" Grid.Column="1" Height="758" Width="1129"/>

</Grid>
注意
当您在
metro应用程序中添加页面时,请记住,您总是从Visual Studio模板中添加
拆分页面
,而不是
空白页面
,因为
拆分页面
包含一些默认内置功能,如
标题
后退按钮
GoBack()
等等。

非常感谢穆罕默德·奥马尔。真主永远保佑你:)你很好。如果我的答案对你有帮助,那就把它标记为答案。
<Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush}">
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="227*"/>
        <ColumnDefinition Width="1139*"/>
    </Grid.ColumnDefinitions>
    <Button Name="firstPageButton" Content="First Page" Grid.Column="0" HorizontalAlignment="Left" VerticalAlignment="Top" Height="53" Width="227" Click="firstPageButton_Click"/>

    <Frame Name="rootFrame" Content="" HorizontalAlignment="Left" VerticalAlignment="Top" Grid.Column="1" Height="758" Width="1129"/>

</Grid>
private void firstPageButton_Click(object sender, RoutedEventArgs e)
{
    rootFrame.Navigate(typeof(Page1),"p");    
}