locked
How is it Master part doesn't need Navigation capabilities, but Detail part does need them? RRS feed

  • Question

  • User97487 posted

    This is the template code (didn't touch it) of Xamarin.Forms for the main page in MasterDetailPage.

    I wonder...How is it that MasterDetailPage.Master doesn't need the capabilities of NavigationPage (as you can see in the code), but MasterDetailPage.Detail does need it (as you can see in the code).

    After all, both of them supply us navigation... :|

    ```

    <MasterDetailPage.Master>
        <views:MenuPage />
    </MasterDetailPage.Master>
    
    <MasterDetailPage.Detail>
        <NavigationPage>
            <NavigationPage.Icon>
                <OnPlatform x:TypeArguments="FileImageSource">
                    <On Platform="iOS" Value="tab_feed.png"/>
                </OnPlatform>
            </NavigationPage.Icon>
            <x:Arguments>
                <views:ItemsPage />
            </x:Arguments>
        </NavigationPage>
    </MasterDetailPage.Detail>
    

    ```

    Monday, July 27, 2020 1:49 PM

Answers

  • User369978 posted

    The master part is always there , it is not moving anywhere(other page) .

    The only changing part is the detail , it displays different page when you switch the items in master .

    Check the code : https://github.com/xamarin/xamarin-forms-samples/blob/72a616c0a7240c8e05ce60cdbd0ff2167dd5aaf6/Navigation/MasterDetailPage/MasterDetailPageNavigation/XAML/MainPage.xaml.cs#L25 .

    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Tuesday, July 28, 2020 8:19 AM

All replies

  • User369978 posted

    I wonder...How is it that MasterDetailPage.Master doesn't need the capabilities of NavigationPage(as you can see in the code), but MasterDetailPage.Detail does need it (as you can see in the code).

    First read the definition of master detail page : The Xamarin.Forms MasterDetailPage is a page that manages two related pages of information – a master page that presents items, and a detail page that presents details about items on the master page.

    The location of the list of items is identical on each platform, and selecting one of the items will navigate to the corresponding detail page.

    Master page : provide the function to switch between different pages, it does not need navigation capabilities . Detail page : display the current page you're selecting , the page could be navigationPage or normal page .

    Of course you can set ContentPage as detail page.

    <MasterDetailPage.Detail>
       <ContentPage/>
    </MasterDetailPage.Detail>
    

    Check the following screen shot for better understanding.


    Refer to

    https://docs.microsoft.com/en-us/xamarin/xamarin-forms/app-fundamentals/navigation/master-detail-page .

    Tuesday, July 28, 2020 3:07 AM
  • User97487 posted

    @ColeX Thank you for the answer. Yes I know that this is the way MasterDetailPage works. The only thing that confuses me is: How does the moving from the slide Menu (The Master) is being done without Navigation mechanism- I'm talking about what is going on "under the hood".

    I thought that every movement from one page to another page, must be done with Navigation some where, and here we see that from the Master part, there is a move with no Navigation. It seems like there is an other mechanism - and this is my question :smile: What is the *mechanism *that enables the movement from the Master part?

    Tuesday, July 28, 2020 4:41 AM
  • User369978 posted

    The master part is always there , it is not moving anywhere(other page) .

    The only changing part is the detail , it displays different page when you switch the items in master .

    Check the code : https://github.com/xamarin/xamarin-forms-samples/blob/72a616c0a7240c8e05ce60cdbd0ff2167dd5aaf6/Navigation/MasterDetailPage/MasterDetailPageNavigation/XAML/MainPage.xaml.cs#L25 .

    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Tuesday, July 28, 2020 8:19 AM
  • User97487 posted

    Thank you very much B)

    Tuesday, July 28, 2020 3:15 PM