Master Detail Page on the right side using Xamarin.Forms

ohkered picture ohkered · Sep 15, 2014 · Viewed 9.2k times · Source

I've created a master detail page on the left side using Xamarin.Forms, how about creating the same for the right side?

Below is my sample code for the left slider menu;

public class App
{
    static MasterDetailPage MDPage;

    public static Page GetMainPage()
    {
        return MDPage = new MasterDetailPage {
            Master = new ContentPage {
                Title = "Master",
                BackgroundColor = Color.Silver,
                Icon = Device.OS == TargetPlatform.iOS ? "menu.png" : null,
                Content = new StackLayout {
                    Padding = new Thickness(5, 50),
                    Children = { Link("A"), Link("B"), Link("C") }
                },
            },
            Detail = new NavigationPage(new ContentPage {
                Title = "A",
                Content = new Label { Text = "A" }
            }),
        };
    }

    static Button Link(string name)
    {
        var button = new Button {
            Text = name,
            BackgroundColor = Color.FromRgb(0.9, 0.9, 0.9)
        };
        button.Clicked += delegate {
            MDPage.Detail = new NavigationPage(new ContentPage {
                Title = name,
                Content = new Label { Text = name }
            });
            MDPage.IsPresented = false;
        };
        return button;
    }
}

Answer

Stephane Delcroix picture Stephane Delcroix · Sep 15, 2014

This does not exists in the Xamarin.Forms controls set, but you can create your own, with renderers for each platform.

You'll find the required information on http://developer.xamarin.com/guides/cross-platform/xamarin-forms/custom-renderer/