I have a project with a MasterDetailPage as root page. When I navigate deeper inside the Detailpage, I have the problem, that the DetailPage navigation overrides my actionbar for the MasterPage. Can I have both in the actionbar, the burgermenuicon and the backbutton?
before navigation: after navigation:
public partial class MasterPage : MasterDetailPage
{
public MasterPage()
{
Master = SetMasterContentPage();
Detail = new NavigationPage(new TaxonomyOverviewPage());
}
ContentPage SetMasterContentPage()
{
var masterPage = new ContentPage { Title = "Test"};
masterPage.Content = new StackLayout
{
Children = {
new Label{Text="Label1"},
new Label{Text="Label2"},
new Label{Text="Label3"}
}
};
return masterPage;
}
protected override void OnAppearing()
{
base.OnAppearing();
}
}
Problem is solved.
I used a public static MasterDetailPage and referenced it to the MainPage in App.cs. Now I can access the IsPresented property of the MasterDetailPage.
public partial class App : Application
{
public static MasterPage masterdetail;
public App()
{
InitializeComponent();
}
protected override void OnStart()
{
masterdetail = new MasterPage();
Device.BeginInvokeOnMainThread(() => {
MainPage = masterdetail;
});
}
}
Finally, I add a menuicon to the right side of the actionbar.
protected override void OnAppearing()
{
base.OnAppearing();
ToolbarItems.Add(new ToolbarItem("Menu", "menuicon.png", () => { App.masterdetail.IsPresented = true; }));
}