1
votes

I've just started to test my app on android tablet and have found a strange bug: I wanted to being masterpage enabled only when my main page is opened. So I created Custom NavigationPage and overrided methods:

/// <summary>
    /// Отключение бокового меню при добавлении на главный экран новых страниц
    /// </summary>
    /// <param name="child"></param>
    protected override void OnChildAdded(Element child)
    {
        base.OnChildAdded(child);
        if (this.Navigation.NavigationStack.Count > 1)
            App.detailPage.IsGestureEnabled = false;
    }

    /// <summary>
    /// Включение бокового меню при наличии только одной страницы на главном экране
    /// </summary>
    /// <param name="child"></param>
    protected override void OnChildRemoved(Element child)
    {
        base.OnChildRemoved(child);
        if (this.Navigation.NavigationStack.Count < 2)
            App.detailPage.IsGestureEnabled = true;
    }

here is my landscape main page:

enter image description here

When I push some pages to my NavigationPage, the master page disappears:

enter image description here

and after that, when I return on my main page, the masterpage is still not available:

enter image description here

At least I need to show my MasterPage on my MainPage, and it would be perfect if somebody tell me, how to hide masterpage to the left and use it with swipe gestures, like on phones. Thanks in advance.

1

1 Answers

2
votes

By the way, I've found the answer for my issue :) Right now, I end up with adding behavior for Tablet idiom in my MasterPage. Constructor's code:

public MasterDetailPage1()
    {
        InitializeComponent();
        /// Some coding
        if (Device.Idiom == TargetIdiom.Tablet)
            MasterBehavior = MasterBehavior.Popover;
        /// Some coding
    }

Hope that helps somebody.