Forum Xamarin.Forms
We are excited to announce that the Xamarin Forums are moving to the new Microsoft Q&A experience. Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

We encourage you to head over to Microsoft Q&A for .NET for posting new questions and get involved today.

Slide Drawer

RexHopeRexHope PHMember ✭✭

Hi all, I am wondering how to properly create a slide drawer in Xamarin Forms.

Here's my code in App.xaml.cs
`MasterDetailPage = new MasterDetailPage
{

                Master = new MenuPage(),
                Detail = new NavigationPage(new Page1())
            };
            MainPage = MasterDetailPage;`

MenuPage.xaml
`

    <ContentPage Title="Menu">
        <StackLayout VerticalOptions="FillAndExpand">
            <Button x:Name="Test" Text="Page 1" TextColor="#7a7a7a"  Margin="0"/>
        </StackLayout>
    </ContentPage>

`

MenuPage.xaml.cs
`public partial class MenuPage : MasterDetailPage
{

    public SideMenuItems()
    {

        InitializeComponent();
        InitializeClickEvents();

    }

    private void InitializeClickEvents()
    {
        Test.Clicked += Test_Clicked;
    }

    private void Test_Clicked(object sender, EventArgs e)
    {
        App.MasterDetailPage.Detail = new NavigationPage(new TestPage());
        App.MasterDetailPage.IsPresented = false;
    }
}`

Page1.xaml
`

<ContentPage.ToolbarItems>
    <ToolbarItem Text="Test" Priority="0" Order="Primary"/>
    <ToolbarItem Text="Settings" Priority="1" Order="Secondary"/>
</ContentPage.ToolbarItems>
<ContentPage.Content>
    <StackLayout>
        <Label Text="Test"/>

    </StackLayout>
</ContentPage.Content>

`

Am I doing it wrong? Cause it wont show on my navigation page.

Sign In or Register to comment.