2015-11-05 102 views
0

您好,我正在使用windows phone 8.1 [RT]应用程序,我只是简单地浏览页面。但我发现,我们可以在XAML中使用Frame也是这样在Windows Phone 8.1中导航的最佳实践[RT] xaml

<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身高电网保持相同,只是导航帧新的选项。 我只想知道哪个是最佳实践使用? 谢谢。

回答

0

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

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

Page1Frame.Navigate(typeof(BlankPage1)); 

如果你想离开通首页去另一页,您应该使用:

var rootFrame = Window.Current.Content as Frame; 
rootFrame.Navigate(typeof(BlankPage1)); 

在这种情况下,您看到的是没有120高度网格的空白页面。