Xamarin forms UWP AppViewBackButtonVisibility.Collapsed doesn't seem to work - xamarin

I'm using Xamarin Forms 3.6.
I want to hide the back button in the UWP app.
In the UWP App.xaml.cs OnLaunced I've added.
SystemNavigationManager
.GetForCurrentView()
.AppViewBackButtonVisibility = AppViewBackButtonVisibility.Collapsed;
I've also added it to each ContentPage (using dependency injection) so that in the constructor of each page runs the above code.
Each content page, I've also added:
NavigationPage.SetHasNavigationBar(this, false);
I always still seem to get the back button in the title bar on UWP.
Any ideas in Xamarin Forms UWP how to hide and keep hidden the back button?

For your requirement, please invoke SetHasBackButton static method in the page where you want to hide back button like the following.
public ItemDetailPage(ItemDetailViewModel viewModel)
{
InitializeComponent();
NavigationPage.SetHasBackButton(this, false);
BindingContext = this.viewModel = viewModel;
}

Related

Navigation animation not working on Xamarin Forms

Default Xamarin forms navigation page animation is not working when using master details page
I am setting the master page from App.Xaml.cs
MainPage = new NavigationPage(new MasterDetailPOS() { });
When I am navigating a page from another page,the second parameter is for animate.
Navigation.PushAsync(new Page1(),true)
page navigation animation not working.
When I am not using master detail page then this animation working fine.
so how to solve this?

How can I prevent additional navigation bar on top of MasterDetailPage (Xamarin on Android)

I am creating an application in Xamarin Forms (4.0) for Android (Android 8.1).
My main page is a MasterDetailPage where I set the detail page to:
this.Detail = new NavigationPage(new SomePage());
When I want to navigate the detail to another page (so that the 'back' button works correctly) I just do:
this.Detail.Navigation.PushAsync(new NavigationPage(new SomeOtherPage());
This all works fine but I am left with an additionl navigation bar with the back button:
If I do NavigationPage.SetHasBackButton(this, false); the back button goes away but the navigation bar is left so I have a big blue rectangle on top of my page. If I do NavigationPage.SetHasNavigationBar(this, false); then both the navigation bar and the titlebar (with hamburger menu) dissappear! Is there a way to just hide the navigation bar with the back button but leave the master/detail title bar (with hamburger menu)?
It seems that the way I've tried to make it work is not really supported by Xamarin Forms. If you navigate the Detail away to another page you effectively loose access to the Master part of the MasterDetailPage (at least on some devices). My attempt to avoid this by wrapping the target Detail page into another NavigationPage works in the Emulator but that is simply by accident.
you only need one instance of NavigationPage
this.Detail.Navigation.PushAsync(new SomeOtherPage());
You can assign the new MasterDetailPage to the root and then handle back pressed. As this isn't suppose to work you must hack a bit.
Make sure that your MainPage is set only to MasterDetailPage.
Once, I had a case that somebody did something like this:
MainPage = new NavigationPage(new MasterDetailPage());
Of course, it should be defined like:
MainPage = new MasterDetailPage();
Then, your DetailPage should be defined only once as it follows:
Detail = new NavigationPage(new MyPage());

How to override back button Title

I have a Xamarin Forms project, where the Android part is working fine. But in the navigation bar of my iOS App I have the problem that the title of some pages are too long.
So what I want to do is just replacing the title of the back button with the title of the page.
I already have a custom NavigationRenderer for some other adjustments in iOS.
In the ViewDidAppear Method of the NavigationRenderer I have tried:
NavigationItem.BackBarButton.Title = NavigationItem.Title;
NavigationItem.Title = "";
But it didn't changed anything. I also tried this with the RootController and even tried this with overriding in a custom ViewController. Nothing worked so far.
So my question is how can I accomplish this? Is the NavigationRenderer the wrong place to do it?
You generally set the back button title in the page the back button refers to i.e. the one before the page that is now showing.
NavigationPage.SetBackButtonTitle(this, "My Short Title");
So you would have to set it before you navigate to the new page if you want the new page title as the back button title.

Xamarin NavigationBar back button click

I am developing a xamarin forms application in which I need to intercept the navigation bar back button. I could do this in android by the
OnOptionsItemSelected method in the activity.
How can I do this in iOS platform? Please help me.
In the XAML Page you can set the has back button to false:
<ContentPage
NavigationPage.HasBackButton="False"
Title="MyPage">
</ContentPage>
And for Android device,you need to disable the physical back button function:
protected override bool OnBackButtonPressed()
{
//return base.OnBackButtonPressed();
return true;
}

Xamarin Form Navigation Bar Color to be changed in Windows platform

I am using a Portable Xamarin form solution to create an Application that will work in IOS, Android and Windows.We are facing a problem in setting the background color of the Navigation Bar. BarBackground color is not working so We tried to change the colors in each Platform but couldn't do it in Windows.
Thanks in Advance.
You are using Xamarin.forms. So, change the constructor of App.Xaml.cs in your PCL.
public App()
{
MainPage = new NavigationPage(new Page1())
{
BarBackgroundColor = Color.Gray
};
}

Resources