Xamarin Cross menu hamburger iOS and Android!

Asked

Viewed 297 times

0

I created an Xamarin Forms Portable project after I created a class with the drop-down menu, I would like to know how to align the Xamarin image in the center, because I am not getting it

using Xamarin.Forms;

namespace MenuHamburguerNavegacao
{
   public class NavigationDrawer : MasterDetailPage
    {
        public NavigationDrawer()
        {
            Title = "Navigation drawer";
            //descrição que irá aparecer no menu a esquerda
            string[] myPageNames = { "Home", "Second", "Third" };

            ListView listView = new ListView
            {
                ItemsSource = myPageNames,
            };

            this.Master = new ContentPage
            {

                Title = "Options",
                Content = listView,
                Icon = "beMobileMenuIconGray.png"
            };

            listView.ItemTapped += (sender, e) =>
            {
                ContentPage gotoPage;
                switch (e.Item.ToString())
                {
                    case "Home":
                        gotoPage = new HomePage();
                        break;

                    case "Second":
                        gotoPage = new HomePage();
                        break;
                    case "Third":
                        gotoPage = new HomePage();
                        break;
                    default:
                        gotoPage = new HomePage();
                        break;
                }

                Detail = new NavigationPage(gotoPage);
                ((ListView)sender).SelectedItem = null;
                this.IsPresented = false;

            };
            Detail = new NavigationPage(new HomePage());
        }
    }
}

In the main class App.Cs

public class App : Application
    {
        public App()
        {
            // The root page of your application
            MainPage = new NavigationDrawer();

        }

It will look like this on android, but also works for windows Ios etc...

inserir a descrição da imagem aqui

  • 1

    You can complement and inform what you want?

  • So far I don’t know any solution that meets the three platforms in the code Portable, would have to be something specific to each platform.

  • Hello, I managed to do following the book of Xamarin Forms, it is possible to create everything only in the Portable project, using mvvm.

  • @Wesleyfavarin Great, you can answer your question with the solution found so it will help other users.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.