C# 在windows phone 8.1[RT]xaml中导航的最佳实践
您好,我正在使用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> <
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高网格的空白页