app.xaml.cs
using Xamarin.Forms;
namespace NaviModel
{
public partial class App : Application
{
public App()
{
InitializeComponent();
MainPage = new NavigationPage(new Page1());
}
protected override void OnStart()
{
// Handle when your app starts
}
protected override void OnSleep()
{
// Handle when your app sleeps
}
protected override void OnResume()
{
// Handle when your app resumes
}
}
}
Page1.xaml
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="NaviModel.Page1"
Title="第一頁">
<ContentPage.Content>
<StackLayout>
<Button x:Name="P1GoNext" Text ="到第二頁" Clicked="P1GoNext_Clicked"></Button>
</StackLayout>
</ContentPage.Content>
</ContentPage>
Page1.xaml.csnamespace NaviModel
{
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class Page1 : ContentPage
{
public Page1 ()
{
InitializeComponent ();
}
private void P1GoNext_Clicked(object sender, EventArgs e)
{
this.Navigation.PushModalAsync(new Page2());
}
}
}
Page2.xaml
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="NaviModel.Page2"
Title="第二頁">
<ContentPage.Content>
<StackLayout>
<Button x:Name="P2GoPre" Text ="到第一頁" Clicked="P2GoPre_Clicked"> </Button>
</StackLayout>
</ContentPage.Content>
</ContentPage>
Page2.xaml.csusing Xamarin.Forms;
using Xamarin.Forms.Xaml;
namespace NaviModel
{
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class Page2 : ContentPage
{
public Page2 ()
{
InitializeComponent ();
}
private void P2GoPre_Clicked(object sender, EventArgs e)
{
this.Navigation.PopModalAsync();
}
}
}
從下圖可以觀察到 Model Page 是不會有巡覽列,也就是不會有 Back 鍵生成最後,Model Page 內是無法混用 Modelless Page 的喔
沒有留言:
張貼留言