Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 58056

MasterDetailPage right aligned ToolbarButton hidden in iPad Landscape mode

$
0
0

If I add a button to the navigation toolbar when a page is created in iPad Landscape orientation and assigned to the Detail of a MasterDetailPage it will not show up. If you start in Portrait and rotate to landscape the button is there. This only happens if you actually construct the page in landscape mode.

I have attached a project that reproduces the issue.

Here is the main snippit from the attached project.

using System;
using Xamarin.Forms;

namespace MasterDetailExample
{
    public class App
    {
        public static MasterDetailPage RootPage;

        public static Page GetMainPage()
        {   
            var homePage = CreateDetailPage("Page 1");

            RootPage = new MasterDetailPage
            {
                Master = new ContentPage
                {
                    Icon = "bars.png",
                    Content = new StackLayout
                    {
                        Children =
                        {
                            CreateMenuButton(1),
                            CreateMenuButton(2),
                            CreateMenuButton(3),
                            CreateMenuButton(4),
                            CreateMenuButton(5),
                        }
                    }
                },
                Detail = homePage,
            };               

            return RootPage;
        }

        public static Button CreateMenuButton(int testIndex)
        {
            return new Button
            { 
                Text = string.Format("Button {0}", testIndex),
                Command = new Command(() =>
                    {
                        RootPage.Detail = CreateDetailPage(string.Format("Page {0}", testIndex));
                        RootPage.IsPresented = false;
                    })
            };
        }

        public static Page CreateDetailPage(string text)
        {
            var page = new ContentPage
            {
                Title = text,
                Content = new StackLayout
                    {
                        Children =
                            {
                                new Label { 
                                    Text = text,
                                    VerticalOptions = LayoutOptions.CenterAndExpand,
                                    HorizontalOptions = LayoutOptions.CenterAndExpand,
                                },

                            }
                        }
            };

            var refresh = new ToolbarItem {
                Command = new Command(() => {  }),
                Icon = "refresh.png",
            };

            page.ToolbarItems.Add (refresh);

            return new NavigationPage(page);
        }
    }
}

Thanks!


Viewing all articles
Browse latest Browse all 58056

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>