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

MasterDetail page iOS Shows No Content

$
0
0

Having an issue on iOS trying to use a MasterDetailPage with the Detail set to a NavigationPage.
The content does not render in the main page. I don't see any errors in the output but when setting a breakpoint
it doesn't hit my OnAppearing override. I adapted this code from the MobileCRM project which works on both platforms
for me. Mine is currently working on Android just fine.

    public class RootPage : MasterDetailPage
    {
        OptionItem _previousItem;

        public RootPage()
        {
            var optionsPage = new MenuPage { Icon = "Icon.png", Title = "menu" };

            optionsPage.Menu.ItemSelected += (sender, e) => NavigateTo(e.SelectedItem as OptionItem);

            Master = optionsPage;

            NavigateTo(optionsPage.Menu.ItemsSource.Cast<OptionItem>().First());
        }

        void NavigateTo(OptionItem option)
        {
            if (_previousItem != null)
                _previousItem.Selected = false;

            option.Selected = true;
            _previousItem = option;

            var displayPage = PageForOption(option);
            Detail = new NavigationPage(displayPage)
            {
                BarBackgroundColor = Helpers.Color.Orange.ToFormsColor()
            };

            Detail.SetValue(TitleProperty, option.Title);
            Detail.SetValue(IconProperty, option.Icon);

            IsPresented = false;
        }

        static Page PageForOption(OptionItem option)
        {
            switch (option.Title)
            {
                case "Home":
                    return new HomePage();
                case "Circles":
                    return new CirclesPage();
                case "Settings":
                    return new SettingsPage ();
                default:
                    throw new NotImplementedException("Unknown menu option: " + option.Title);
            }
        }
    }

Viewing all articles
Browse latest Browse all 58056

Trending Articles



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