)
We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to Navigate to a page in SfNavigationDrawer

Platform: Xamarin.Forms |
Control: SfNavigationDrawer |
Published Date: March 13, 2017 |
Last Revised Date: June 24, 2019

Syncfusion NavigationDrawer provides the feature of navigation from one page to another page.

 

To navigate from one page to another follow the below given procedure.

 

Step 1: Create the navigation drawer with all necessary assemblies.

Step 2: Enter the code in App.xaml.cs page as such. And also use the below given codes in the respective pages.

 

The below code illustrates how to navigate to another page.

Code behind code for main page:

namespace DrawerExample
{
public partial class MainPage : ContentPage
{
    public MainPage()
    {
        InitializeComponent();
        SfNavigationDrawer navigationDrawer = new SfNavigationDrawer();
        Title = "Navigation Drawer";
        //Drawer content.
        Grid drawercontentlayout = new Grid();
        Label drawer = new Label();
        drawer.Text = "Drawer Content";
        drawer.FontSize = 14;
        drawer.TextColor = Color.Black;
        drawer.HorizontalTextAlignment = TextAlignment.Center;
        drawer.VerticalTextAlignment = TextAlignment.Center;
        drawercontentlayout.Children.Add(drawer);
        navigationDrawer.DrawerContentView = drawercontentlayout;
 
        //Header 
        Grid headerLayout = new Grid();
        headerLayout.BackgroundColor = Color.FromHex("#1aa1d6");
        Label header = new Label();
        header.Text = "Header View";
        header.FontSize = 14;
        header.TextColor = Color.White;
        header.HorizontalTextAlignment = TextAlignment.Center;
        header.VerticalTextAlignment = TextAlignment.Center;
        header.BackgroundColor = Color.FromHex("#1aa1d6");
        headerLayout.Children.Add(header);
        navigationDrawer.DrawerHeaderView = headerLayout;
 
        //Footer 
        Grid footerlayout = new Grid();
        footerlayout.BackgroundColor = Color.FromHex("#1aa1d6");
        Label footer = new Label();
        footer.Text = "Footer View";
        footer.FontSize = 14;
        footer.TextColor = Color.White;
        footer.HorizontalTextAlignment = TextAlignment.Center;
        footer.VerticalTextAlignment = TextAlignment.Center;
        footer.BackgroundColor = Color.FromHex("#1aa1d6");
        footerlayout.Children.Add(footer);
        navigationDrawer.DrawerFooterView = footerlayout;
 
        navigationDrawer.Position = Position.Left;
        navigationDrawer.Transition = Transition.SlideOnTop;
        navigationDrawer.DrawerWidth = 200;
        navigationDrawer.DrawerHeaderHeight = 50;
        navigationDrawer.DrawerFooterHeight = 50;
 
        StackLayout stack = new StackLayout();
        Button bt = new Button();
        bt.Text = "Next_Page";
        bt.VerticalOptions = LayoutOptions.CenterAndExpand;
        bt.HorizontalOptions = LayoutOptions.CenterAndExpand;
        bt.Clicked += Bt_Clicked;
        stack.Children.Add(bt);
        navigationDrawer.ContentView = stack;
 
        this.Content = navigationDrawer;
 
    }
 
    async void Bt_Clicked(object sender, System.EventArgs e)
    {
        await Navigation.PushAsync(new NavigationPage2());
    }
}
}
 

Navigation page XAML code:

<!--Navigation page content--> 
<StackLayout>        
  <Label Text="Navigated Page" VerticalOptions="CenterAndExpand" HorizontalOptions="CenterAndExpand" />       
</StackLayout>   

 

In App.xaml.cs page. Use the following code:

public App()
{
InitializeComponent();
 
MainPage = new NavigationPage(new DrawerExample.MainPage());
}

 

Main page with Opened:

Main page with Opened in SfNavigationDrawer

Navigated page:

Navigated page in SfNavigationDrawer

 

 

 

2X faster development

The ultimate Xamarin UI toolkit to boost your development speed.
ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon