I am trying to add a back button to the toolbar and I have read that it can be done using the following in the constructor
NavigationPage.SetHasBackButton(this,true);
I have also added the same in xaml in the ContentPage
NavigationPage.HasBackButton="True" NavigationPage.BackButtonTitle="Search"
but I cant see my title shown in the toolbar or the arrow for the back button. What am I doing wrong. Is this due to the fact that I am using FreshMVVM
I have got it working now,I was loading the page as a modal and the back button was not showing. Loading the page as a non modal did the trick. However the title of the back button seems to say 'Back' somehow even after specifying a value for the title
Update
The title of the previous page was not set , setting it to a value changes the title of the back button to be the same. I thought we could enforce the back button to have a different value through the call from the constructor but that didnt work for me
Have a look at this post by James Montemagno. In XAML add the NavigationPage.BackButtonTitle to the ContentPage. Remember this is set on the page you want to navigate back to, not on the page currently displayed. I'm using this with a FreshMvvm project.
<ContentPage
xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:ios="clr-namespace:Xamarin.Forms.PlatformConfiguration.iOSSpecific;assembly=Xamarin.Forms.Core"
ios:Page.UseSafeArea="true"
x:Class="MyProject.Pages.MyPage"
NavigationPage.BackButtonTitle="Back"
Title="My Page Title">
...
</ContentPage>
Related
With the standard (template) implementation of Master Detail Page, I do not get a back button when I call the side menu.
Standard implementation looks like this:
<NavigationPage>
<x:Arguments>
<local:DetailPage1/>
</x:Arguments>
</NavigationPage>
But when I implement navigation in this way:
MainPage = new NavigationPage(new MainPage());
i get the button back
Why does this happen and why I do not get a button with the standard (template) implementation? Thanks
screenshot with a running button at the bottom
enter image description here
First of all - the menu (master page) should not have a back button.
From the official documentation:
A MasterDetailPage is designed to be a root page, and using it as a
child page in other page types could result in unexpected and
inconsistent behavior. In addition, it's recommended that the master
page of a MasterDetailPage should always be a ContentPage instance,
and that the detail page should only be populated with TabbedPage,
NavigationPage, and ContentPage instances. This will help to ensure a
consistent user experience across all platforms.
If your MasterDetailPage is not a root page and it is wrapped by a NavigationPage you may see the back arrow.
That should answer your question. Additional details and restrictions are listed in the same official doc.
I need to add a back button to my navigation page. I tried NavigationPage.SetHasBackButton(page, true); but it didn't work and I tried in xaml also, still does not work. Can anybody help me?
Your code isn't right. In App.xaml.cs you need to set Main page to be new NavigationPage(new ProductDetail());
Then when you navigate away from ProductDetail, you will see the back button.
Also normal page navigation will use PushAsync. Are you wanting a modal popup for your second page?
I'm using Xamarin.Forms with PRISM. My app start with navigating to MyMasterDetailPage/MyNavigationPage/MainPage. From the master page, I want to navigate to page2 and have a back arrow instead of the hamburger icon. Pressing that takes you back to MainPage and the hamburger icon is back. I have tried navigating to MyNavigationPage/page2 andMyMasterDetailPage/MyNavigationPage/page2` but it seems to be clearing the back stack. There may be other pages that need the behavior that I'm currently seeing, so being able to configure the behavior would be ideal (not always one way or the other).
You need to implement the INavigationPageOptions interface on your MyNavigationPage and set the ClearNavigationStackOnNavigation property to false.
I am using Xamarin Forms, added the below code for Toolbar, but it not showing on the right top (with 3 dots) and but I could see Menu when I use Menu hardware button on device.
Device running Android Jelly bean 4.3.
<ToolbarItem Text="QUICK LINKS" Activated="OnToolBarClick" Order="Secondary" Priority="0" />
Any suggestion?
Make sure that when you create the instance of the page containing the toolbar, you use the NavigationPage class to wrap it, otherwise the toolbar will not be displayed.
For example, assume UpdateScoresPage is the page with the toolbar in, and we're calling this from the parent page. If you omit new NavigationPage(page) the toolbar will not show.
UpdateScoresPage page = new UpdateScoresPage(Model, model);
await Navigation.PushModalAsync(new NavigationPage(page));
I used bootstrap 3 modal dialog for search function in my asp.net inventory application.When I press the search button on my modal content whole popup up dialog went disappeared.I want to lock the the modal dialog in my current page window.How can I resolve this using bootstrap.I tried putting data-backdrop: static.But it's still not work for me.
Try also passing the
{keyboard: false}
Option as well as data-backdrop: false. Technically speaking data-backdrop should be solving your problem. Is theres something that makes your project unique?