简体   繁体   中英

Navigating through pages in Xamarin without changing the entire content of the page

https://i.stack.imgur.com/TNKac.png

Is there a way that I can do this in Xamarin.Forms like the picture above? In UWP, I can do this by using Frame element and I can navigate through pages without changing the entire content.

Are you looking for Master Detail Layout like attached? Created in Xamarin.Forms . Help me understand your question!

主细节布局

I think you can use MasterDetailPage . You have a MasterPage (on the left) and DetailPage(on the right) that you can change when you press your item in the Master.

This is how you can create in C# a MasterDetail

public class MainPageCS : MasterDetailPage
{
    MasterPageCS masterPage;

    public MainPageCS ()
    {
        masterPage = new MasterPageCS ();
        Master = masterPage;
        Detail = new NavigationPage (new ContactsPageCS ());
    }
}

The MasterDetailPage.Master property is set to a ContentPage instance. The MasterDetailPage.Detail property is set to a NavigationPage containing a ContentPage instance.

Otherwise if you don't like MasterDetail, you can "simple" use a Grid with 2 rows X 2 columns. Then you can use a ContentView for your menu (it should use Grid.SetRowsSpan (menuContentView, 2); so your contentView fill 2 rows.

Then you can use a Label for the title and another ContentView for your "Page"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM