How do you switch pages in Xamarin.Forms?

后端 未结 13 1259
我在风中等你
我在风中等你 2020-12-02 07:08

How do you switch between pages in Xamarin Forms?

My main page is a ContentPage and I don\'t want to switch to something like a Tabbed Page.

I\'ve been abl

13条回答
  •  没有蜡笔的小新
    2020-12-02 07:44

    In App.Xaml.Cs:
    
    MainPage = new NavigationPage( new YourPage());
    

    When you wish to navigate from YourPage to the next page you do:

    await Navigation.PushAsync(new YourSecondPage());
    

    You can read more about Xamarin Forms navigation here: https://docs.microsoft.com/en-us/xamarin/xamarin-forms/app-fundamentals/navigation/hierarchical

    Microsoft has quite good docs on this.

    There is also the newer concept of the Shell. It allows for a new way of structuring your application and simplifies navigation in some cases.

    Intro: https://devblogs.microsoft.com/xamarin/shell-xamarin-forms-4-0-getting-started/

    Video on basics of Shell: https://www.youtube.com/watch?v=0y1bUAcOjZY&t=3112s

    Docs: https://docs.microsoft.com/en-us/xamarin/xamarin-forms/app-fundamentals/shell/

提交回复
热议问题