Xamarin Forms: how to hide back button title? - xamarin

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?

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).

There is also one workaround to hide back button title globally in whole application.
Add in your AppDelegate.cs in FinishedLaunching method:
UIBarButtonItem.Appearance.SetBackButtonTitlePositionAdjustment (new UIOffset (-100, -60), UIBarMetrics.Default);

Adding to Cuckooshka answer, back button title gets hidden in landscape mode as
UIBarButtonItem.Appearance.SetBackButtonTitlePositionAdjustment (new UIOffset (-100, -60), UIBarMetrics.LandscapePhone);

If you navigate from Page1 to Page2, then in Page1:
public Page1()
{
NavigationPage.SetBackButtonTitle(this, "");
InitializeComponent();
}
If everything is correct, in Page2 you will not see the title of navigation bar.

Related

Xamarin.Forms: Navigation away from Master Page loses arrow

I am having this little drawer menu in my master detail page. I have a list with clickable options there and some navigate you to another screen:
Application.Current.MainPage = new NavigationPage(new Screen_Profile("", true));
But this results in the loss of the navigation arrow to go back. If you click back on android, the app just closes afterwards.
How can I navigate away from the master detail page and still have the arrow to just come back to the main page?
Thank you!
you only want to update the Detail page, your the entire MainPage
var mdPage = (MasterDetailPage)Application.Current.MainPage;
mdPage.Detail = new NavigationPage(new Screen_Profile("", true));
this will leave the Master portion of the page with it's menu active as you Navigate

Different Types of Navigation in Xamarin Forms

What is the difference between these two Navigation paradigms in Xamarin.Forms?
await Navigation.PushModalAsync(new Dashboard());
await Navigation.PushModalAsync(new NavigationPage(new Dashboard()));
What is a Modal Page
Navigation.PushModalAsync will cause the new Xamarin.Forms.Page to appear Modally, meaning its animation will start from the bottom of the screen, covering the previous current page and it will not contain a back-button.
On iOS, a user will not be able to swipe-left to return to the previous page.
Android users are able to use the hardware back button to dismiss a modal page.
Modal pages are useful when you want the user to make a conscious decision to dismiss the page.
Example
When an iOS user is filling out a form and they swipe left to go back, does it save the form or discard the form? It is unclear to the user. To make the UX more intuitive, you should display the form modally
UI Differences
Using await Navigation.PushModalAsync(new Dashboard()); will display the Dashboard Page Modally, but the new Page will not have a NavigationBar.
Using await Navigation.PushModalAsync(new NavigationPage(new Dashboard())); will also display the Dashboard Page Modally, but the new Page will have a NavigationBar.
Sample App Source Code: https://github.com/brminnick/XamList
Edit
#AlessandroCaliaro and I had a good discussion in the comments of his answer, below:
It's important to note that Xamarin.Forms.INavigation uses two different stacks, ModalStack and NavigationStack. Navigation.PushModalAsync adds a Page to the ModalStack and Navigation.PushAsync adds a Page to the NavigationStack.
And to pop a Page from the ModalStack, you need to use Navigation.PopModalAsync(), whereas you would use Navigation.PopAsync() to remove a Page from the NavigationStack.
The first, push a page in a "modal" way (without navigation bar on the top)
the second... is an error because you try to add a navigationpage to a navigationstack, but I think it is not possible....

Xamarin Forms Prism Navigation from TabbedPage behaves as PushModelAsync or the navigation bar disappears

In Tabbed page sample given by Prism, I want to navigate from ViewA (first tab) to ViewD(not the next tab but next navigation page).
I don't understand why this removes the navigation bar on the top:
_navigationService.NavigateAsync(nameof(ViewD));
Like PushModelAsync instead of PushAsync. So that I loose the back button on the navigation tab which is not intended.
Am I missing something here?
The reason for this is that ViewA’s parent is not a NavigationPage, the result is that the Navigation Service assumes you want modal Navigation. You simply need to add useModalNavigation: false, this will make the Navigation Service push ViewD correctly inside the Navigation Page.

How to dismiss modal navigation page using Prism NavigationService?

In my root view model I call something like
await _navigationService.NavigateAsync(
"/NavigationPage/Page1of2",
useModalNavigation: true
);
Sure enough it loads both view models in a modal navigation just fine. In Page1of2ViewModel I do another
await _navigationService.NavigateAsync(
"Page2of2",
useModalNavigation: false
);
Which view model now should dismiss that modal and how?
Using GoBackAsync() or GoBackAsync(useModalNavigation: true) neither of the 3 view model seem to be able to dismiss the modal flow back to my root view model.
When you place a "/" in you are signifying an absolute navigation. This is resetting the navigation stack completely. It's the same as MainPage = new MyPage(). So there is no modal navigation occurring here. The only way to pop a page off the stack is to use the NavigationService.GoBackAsync, or use the built-in software/hardware buttons to go back.

Extjs 4 window hide or destroy

Hi,
I'm implementing a layout with Extjs 4 as shown in the image.
The layout contains
4 tab panels
Each tab content will be loaded dynamically. The loaded page contains left navigation panel and right side container to load the respective page
The page which is loaded in right side container will have a button
When the button is clicked a pop will be shown
I'm showing one pop up in page1 and another different pop up in page2.
What my problem is
when i click the button on the 1st page its showing a popup (say pop up 1),
for the second page when i click on the button it has to show pop up2, which contains some panels.
But pop up 1 appears in the second page.
the same pop up appears in all the sub pages.
if i reload the entire page and directly go to the page2 it shows the pop2.
i think that the window once created will persist until the page is reloaded.
i'm using window as follows
var createLessonWin = Ext.widget('window', {
autoHeight:true,
id: 'cformWin',
closeAction: 'hide',
y: 100,
modal: true,
plain: true,
layout: 'fit',
items: profile_form
});
Ext.get('add_lessons_btn').on('click', function () {
createLessonWin.show();
});
if i use closeAction: 'destroy' window elements also destroyed.
i tried with Ext.create('Ext.window.Window', {}) and new Ext.Window also. the same problem appears.
Content of the pop up in each page is a different form
How to solve this problem
I'm assuming you only use that code for one of the two windows. The items property is what goes in the window, so you'll need that to be different for the two buttons. Secondly, make sure your ids are unique for each window.
If you post some more code, I might have a better idea of what's going on. How do you create your other window?

Resources