I have created a new Blank App (Xamarin.Forms Portable) project in Visual Studio 2015 and modified App.cs to get "hamburger menu":
public class App : Application
{
public App()
{
var masterPage = new ContentPage()
{
Content = new Label { Text = "Hello from Master!"},
Title = "Master Page"
};
var detailPage = new ContentPage()
{
Content = new Label { Text = "Hello from Detail!" },
Title = "Detail Page"
};
var mainPage = new MasterDetailPage()
{
Master = masterPage,
Detail = detailPage,
Title = "Main Page"
};
// The root page of your application
MainPage = mainPage;
}
. . .
}
Everything works fine, but how can I customize these four things:
1) Hide / change Arrow
2) Hide / change Icon
3) Hide / change Title text
4) Hide whole toolbar
You can change arrow to hamburger icon if you use your DetailPage
within NavigationPage
:
Detail = new NavigationPage(detailPage);
To change icon, just change project files:
or on your MasterDetailPage
set Icon
property to another resource.
If you want to hide icon - it only applies to Android. It can be solved with custom renderer (http://developer.xamarin.com/guides/cross-platform/xamarin-forms/custom-renderer/):
public class CustomNavigationRenderer : NavigationRenderer
{
protected override void OnElementChanged(ElementChangedEventArgs<NavigationPage> e)
{
base.OnElementChanged (e);
var actionBar = ((Activity)Context).ActionBar;
actionBar.SetIcon (Resource.Color.transparent);
}
}
EDIT: It can also be done in MainActivity.cs:
ActionBar.SetIcon (new ColorDrawable(Resources.GetColor (Android.Resource.Color.Transparent)));
Just use Title
property on Page
.
SetHasNavigationBar(page, false);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With