Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/256.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 在windows phone 8.1[RT]xaml中导航的最佳实践_C#_Xaml_Navigation_Windows Phone 8.1_Frame - Fatal编程技术网

C# 在windows phone 8.1[RT]xaml中导航的最佳实践

C# 在windows phone 8.1[RT]xaml中导航的最佳实践,c#,xaml,navigation,windows-phone-8.1,frame,C#,Xaml,Navigation,Windows Phone 8.1,Frame,您好,我正在使用windows phone 8.1[RT]应用程序,我只需浏览页面。但我发现了新的选项,我们可以在xaml中使用Frame,也可以这样 <Grid> <Grid.RowDefinitions> <RowDefinition Height="120"/> <RowDefinition Height="*"/> </Grid.RowDefinitions> <

您好,我正在使用windows phone 8.1[RT]应用程序,我只需浏览页面。但我发现了新的选项,我们可以在xaml中使用
Frame
,也可以这样

  <Grid>
    <Grid.RowDefinitions>
        <RowDefinition Height="120"/>
        <RowDefinition Height="*"/>
    </Grid.RowDefinitions>

    <Border Background="White">

    </Border>
    <Button Content="next" Click="Button_Click" Background="Black" />

    <Grid Grid.Row="1">

        <Frame x:Name="Page1Frame" Background="Black" >
            <StackPanel>
                <Rectangle Height="100" Width="100" Fill="Red" Margin="5" />

                <Rectangle Height="100" Width="100" Fill="Red" Margin="5" />
                <Rectangle Height="100" Width="100" Fill="Red" Margin="5" />
                <Rectangle Height="100" Width="100" Fill="Red" Margin="5" />
            </StackPanel>
        </Frame>
    </Grid>

</Grid>
private void Button_Click(object sender, RoutedEventArgs e)
{
        Page1Frame.Navigate(typeof(BlankPage1));
}
在本例中,我的120高度栅格保持不变,只需导航框架。 我只是想知道使用哪种方法是最好的?
多谢各位

页面就是页面,框架就是框架,它们是不同的

假设您当前的页面名为MainPage,如果您想留在MainPage并更改根网格第1行中网格的内容,您应该使用:

 Page1Frame.Navigate(typeof(BlankPage1));
var rootFrame = Window.Current.Content as Frame; 
rootFrame.Navigate(typeof(BlankPage1));
如果要离开主页转到其他页面,应使用:

 Page1Frame.Navigate(typeof(BlankPage1));
var rootFrame = Window.Current.Content as Frame; 
rootFrame.Navigate(typeof(BlankPage1));
在这个例子中,你看到的是一个没有120高网格的空白页