In my app, I have "RootPage" that inherits from MasterDetailPage. This is my MainPage for the Application. I have a "MenuPage" that inherits from ContentPage that creates the menu items. I set that to Master in "RootPage". Then I create a new NavigationPage, passing in page with a list view to the constructor. I then set the Detail to the NavigationPage. In the listview page, OnItemSelected I navigate with Navigation.PushAsync(detailsPage)
. Following this pattern, when the detailsPage loads, the "hamburger/sliding menu" is not there in iOS and instead I can only go back to the previous page (List view). Here are code examples:
public class RootPage : MasterDetailPage {
MenuPage menuPage;
public RootPage() {
menuPage = new MenuPage();
menuPage.Menu.ItemSelected += (sender, e) =>
NavigateTo(e.SelectedItem as Model.MenuItem);
Master = menuPage;
Detail = new NavigationPage(PlayerListPage());
}
}
public class PlayerListPage : ContentPage {
protected async void OnItemSelected(object sender, ItemTappedEventArgs e) {
var item = e.Item as PlayerViewModel;
var selected = new PlayerPage(item) {
BindingContext = item
};
await Navigation.PushAsync(selected);
}
}
public class MenuPage : ContentPage {
public ListView Menu { get; set; }
public MenuPage() {
Icon = "menu.png";
Title = "menu"; // The Title property must be set.
var menuItems = new List<MenuItem> {
new MenuItem {
Title = "Players",
IconSource = "people.png",
TargetType = typeof(PlayerListPage)
},
};
Menu = new ListView {
ItemsSource = menuItems,
};
}
}
public class MenuItem {
public string Title { get; set; }
public string IconSource { get; set; }
public Type TargetType { get; set; }
}
Is this what you are trying to achieve? If not, then you clarify what you mean by disable the sliding menu
and provide more code samples.