Xamarin Forms: how to hide back button title?

后端 未结 4 2158
一个人的身影
一个人的身影 2021-02-20 04:54

In my Xamarin Forms iOS application the previous page name is also appearing with the back button in all pages. Is there any way to hide the title of the previous page?

4条回答
  •  梦谈多话
    2021-02-20 05:51

    If you use Navigation Page, you can use an empty string for the Back button title:

    NavigationPage.SetBackButtonTitle(this, ""); //Empty string as title
    

    As far as I remember, it will affect the next page on the navigation stack (the page after 'this' will have an empty Back button title). Don't quote me on this.

    You can completely hide the Back button with:

    NavigationPage.SetHasBackButton(this, false);
    

    Another option is to use a Modal page by replacing Navigation.PushAsync(yourPage) with Navigation.PushModalAsync(yourPage) which will present the page modally.

    FYI, the back button is automatically populated with the Title property of the previous page (or it will default to Back if the Title was not set).

提交回复
热议问题