将 Android TabHost 移植到 Windows Phone
Porting Android TabHost to Windows Phone
我正在将我的一个 Android 应用移植到 WinPhone 8.1 和 10 (UWP)。该应用程序本身使用 TabHost,它将各个活动加载到每个选项卡中,然后在按下时显示在每个选项卡中。
在 WinPhone 上,我使用 Pivot 来做同样的事情。看起来我需要在打开枢轴的情况下为视图上的枢轴项设置 UI。我不认为这是事实,因为它没有意义。
有没有办法让枢轴项目 1 加载它链接到的页面,但仍然在顶部有枢轴?
Is there a way to have it that pivot item 1 loads the page it links to but still has the pivot at the top?
我想你可能想在点击Pivot
的header时将Pivot
的内容导航到某个页面,如果是这样,就没有必要使用[=14] =].您需要的是 Frame 控件。
首先,我们需要知道Pivot中有Header部分和Content部分。您需要的是始终显示 Header。
例如,您可以这样编码:
<Pivot>
<PivotItem Header="Page 1">
<Frame x:Name="frame1" />
</PivotItem>
<PivotItem Header="Page 2">
<Frame x:Name="frame2" />
</PivotItem>
<PivotItem Header="Page 3">
<Frame x:Name="frame3" />
</PivotItem>
</Pivot>
在后面的代码中,您可以在此 Frame
控件中导航,例如:
protected override void OnNavigatedTo(NavigationEventArgs e)
{
frame1.Navigate(typeof(MainPage));
frame2.Navigate(typeof(Page2));
frame3.Navigate(typeof(Page3));
}
我正在将我的一个 Android 应用移植到 WinPhone 8.1 和 10 (UWP)。该应用程序本身使用 TabHost,它将各个活动加载到每个选项卡中,然后在按下时显示在每个选项卡中。
在 WinPhone 上,我使用 Pivot 来做同样的事情。看起来我需要在打开枢轴的情况下为视图上的枢轴项设置 UI。我不认为这是事实,因为它没有意义。
有没有办法让枢轴项目 1 加载它链接到的页面,但仍然在顶部有枢轴?
Is there a way to have it that pivot item 1 loads the page it links to but still has the pivot at the top?
我想你可能想在点击Pivot
的header时将Pivot
的内容导航到某个页面,如果是这样,就没有必要使用[=14] =].您需要的是 Frame 控件。
首先,我们需要知道Pivot中有Header部分和Content部分。您需要的是始终显示 Header。
例如,您可以这样编码:
<Pivot>
<PivotItem Header="Page 1">
<Frame x:Name="frame1" />
</PivotItem>
<PivotItem Header="Page 2">
<Frame x:Name="frame2" />
</PivotItem>
<PivotItem Header="Page 3">
<Frame x:Name="frame3" />
</PivotItem>
</Pivot>
在后面的代码中,您可以在此 Frame
控件中导航,例如:
protected override void OnNavigatedTo(NavigationEventArgs e)
{
frame1.Navigate(typeof(MainPage));
frame2.Navigate(typeof(Page2));
frame3.Navigate(typeof(Page3));
}