简体   繁体   English

在Xamarin中浏览页面而不更改页面的全部内容

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

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

Is there a way that I can do this in Xamarin.Forms like the picture above? 有没有办法在Xamarin.Forms中完成上述操作? In UWP, I can do this by using Frame element and I can navigate through pages without changing the entire content. 在UWP中,我可以通过使用Frame元素来做到这一点,并且可以在不更改整个内容的情况下浏览页面。

Are you looking for Master Detail Layout like attached? 您是否正在寻找像附件一样的主细节布局 Created in Xamarin.Forms . Xamarin.Forms中创建。 Help me understand your question! 帮我了解您的问题!

主细节布局

I think you can use MasterDetailPage . 我认为您可以使用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. 您有一个MasterPage(在左侧)和DetailPage(在右侧),您可以在按下Master中的项目时进行更改。

This is how you can create in C# a MasterDetail 这是您可以在C#中创建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. MasterDetailPage.Master属性设置为ContentPage实例。 The MasterDetailPage.Detail property is set to a NavigationPage containing a ContentPage instance. MasterDetailPage.Detail属性设置为包含ContentPage实例的NavigationPage。

Otherwise if you don't like MasterDetail, you can "simple" use a Grid with 2 rows X 2 columns. 否则,如果您不喜欢MasterDetail,则可以“简单”使用2行X 2列的网格 Then you can use a ContentView for your menu (it should use Grid.SetRowsSpan (menuContentView, 2); so your contentView fill 2 rows. 然后,您可以将ContentView用于菜单(它应该使用Grid.SetRowsSpan (menuContentView, 2);因此contentView填充2行。

Then you can use a Label for the title and another ContentView for your "Page" 然后,您可以将标签用作标题,将另一个ContentView用于“页面”

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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