コード例 #1
0
        public NavigationDrawer()
        {
            InitializeComponent();
            string[] myPageNames = { "Home", "Second", "Third" };
            menu.ItemsSource = myPageNames;

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

                case "Second":
                    gotoPage = new SecondPage();
                    break;

                case "Third":
                    gotoPage = new ThirdPage();
                    break;

                default:
                    gotoPage = new NavigationPage1();
                    break;
                }
                Detail = new NavigationPage(gotoPage);
                ((ListView)sender).SelectedItem = null;
                this.IsPresented = false;
            };

            Detail = new NavigationPage(new HomePage());
        }
コード例 #2
0
        public zNavigationDrawer()
        {
            Title = "Navigation Drawer Using MasterDetailPage";
            string[] myPageNames = { "Home", "Second", "Third" };

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

            this.Master = new ContentPage
            {
                Title   = "Options",
                Content = listView,
                Icon    = "hamburger.png"
            };

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

                case "Second":
                    gotoPage = new SecondPage();
                    break;

                case "Third":
                    gotoPage = new ThirdPage();
                    break;

                default:
                    gotoPage = new NavigationPage1();
                    break;
                }
                Detail = new NavigationPage(gotoPage);
                ((ListView)sender).SelectedItem = null;
                this.IsPresented = false;
            };

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