Forum Xamarin.Forms

Master Detail Page: Config Detail Page to Slide With Master Menu Rather than Menu Above

pmhart83pmhart83 USMember ✭✭✭
edited September 2016 in Xamarin.Forms

I noticed that MasterDetailPage has a "MasterBehavior" property which I currently have set to MasterBehavior.Popover.

Currently our menu slides on top of the detail page. We would like it to slide WITH the detail page and push the detail page x coordinate over as far as the menu is open. I have seen this before, and while setting the MasterBehavior to Split sort of achieves this the menu always stays open.

Does anyone know how to get a slide-able master menu that slides over the detail page not on top in iOS? I guess I could create my own custom UI for this but hoping there is something quick I could do.

Posts

  • pmhart83pmhart83 USMember ✭✭✭
    edited September 2016

    Here is what I have learned since posting yesterday:

    1

    I can use a "PhoneMasterDetailRenderer" for the tablet MasterDetailPage but it goes 80% the width and looks bad.

    Looking at the source for this renderer here:
    https://github.com/xamarin/Xamarin.Forms/blob/eb79ff842e701ca4d2c9e1c9d02f654fd2c0f058/Xamarin.Forms.Platform.iOS/Renderers/PhoneMasterDetailRenderer.cs

    The function:
    void LayoutChildren(bool animated)

    The 80% is hardcoded and the function is not virtual.

    2

    If I extend TabletMasterDetailRenderer I can get the open animation to work if I override:
    ViewDidLayoutSubviews()

    With the following logic

    public override void ViewDidLayoutSubviews() { base.ViewDidLayoutSubviews(); if(View.Subviews.Length >= 2) { var x = 0; if((Element as MasterDetailPage).IsPresented) x = 320; var detailView = View.Subviews[1]; detailView.Frame = new CoreGraphics.CGRect(x,0,detailView.Frame.Width,detailView.Frame.Height); } }

    But ViewDidLayoutSubviews does not happen when the menu closes so the detail page stays at an offset x 320.

    3

    Write my own ... I could basically just copy all the open source from https://github.com/xamarin/Xamarin.Forms just to change that 80% however after adding 6 extra classes it was getting to be too many dependencies and was still not all there. Would be easier just to write one custom scrollview.

Sign In or Register to comment.