How to switch pages in the Xamarin Shell without a back button? - xamarin

I want to make a home button at the top of the Shell-based APP.
(Referring to the Xanimals app.)
The purpose of this home button is to move to one of the specific Routined pages in the Shell.
The gotoasync() function adds the previous page to the navigation stack by default, and the Backward button is enabled.
I don't want the back button, I just want to move like when you press the flyout button in Shell structure.
Please help me.

You could try this method which switches to a different navigation stack; assuming the home view is registered with a route name of home in your AppShell.xaml
await Shell.Current.GoToAsync("//home");
Here's a reference to all route formats:
https://learn.microsoft.com/en-us/xamarin/xamarin-forms/app-fundamentals/shell/navigation#absolute-routes

Try the below method :
in your home button click event:
Shell.Current.CurrentItem.CurrentItem.Items.Add(Your new Page);
Shell.Current.CurrentItem.CurrentItem.Items.RemoveAt(0);

Related

Xamarin Master Detail prism Nav bar back button

I have a masterdetailview that uses prism. When I click on one of the menu items the hamburger menu shows up on the nav bar of the new page I clicked and I really just want the top nav bar to show a back button and be able to go back. How can I achieve this ?
When my app loads I call
await NavigationService.NavigateAsync("/MainPage/NavigationPage");
I figured I could call
await NavigationService.NavigateAsync("/MainPage/NavigationPage/InviteFriends");
and this would provide the newpage with a back button to Home but when I do this it doesn't do anything
EDIT
if I change to
await NavigationService.NavigateAsync("/MainPage/NavigationPage/FeaturePage");
which is what the home page will be called(Feature Page) it will not load the page at all.
MainPage is my list of other pages to go to that is shown when the hamburger is pressed if that helps. Feature page is the page I would want to show below the hamburger page and be the "Home" screen.
am I doing that correctly ?
So if we take your example you have the following Navigation Stack:
MainPage/NavigationPage
Let's assume your navigation code looks like this in the Master-Detail View Model
await NavigationService.NavigateAsync("/MainPage/NavigationPage/InviteFriends");
This will lead to the following Navigation Stack:
/MainPage/NavigationPage/InviteFriends
This is because the navigation was called from the master-detail page.
The master-detail page is considered a root page in Prism and when navigating from a Master-detail page it will set the target page as the detail page of the master-detail.
Check out this article for a more detailed breakdown Link
Be careful - Starting with /MainPage will clear the Navigation stack
One quick solution to this is to add your homepage to the navigation call:
await NavigationService.NavigateAsync("MainPage/NavigationPage/HomePage/InviteFriends");
This will create the following:
MasterDetailPage/NavigationPage/HomePage/InviteFriends
This should hopefully create the response you are looking for.
Hope this helped. Happy coding!
EDIT:
I think if you separate your initial Detail Page out into its own file you should then be able to do the following:
await NavigationService.NavigateAsync("MainPage/NavigationPage/HomePage/InviteFriends");

Force reload component in Nativescript

I want to re-create and animate the same view back when navigated to same page.
this.routerExtension.navigate(['/home']);
Currently if i am in home page and button is tapped in same page which fires the above code, the component is not reloaded. I want to forcefully reload and animate the same view into stack.
It is a bit of a hack, but I got around this by making two routes that refer to the same component, something like '/home' and '/home1', then alternating which one I used.
It would be nice if there was an option in routerExtension to do this.

xamarin - apply consistent navigation across all content page

I am developing an APP using Xamarin, i trying to apply an consistent navigation system for my app.
I have used xamarin master detail navigation and binded the master page with few details page through ObservableCollection list.
My default details page is again a tabbled page. Within Tabled page on click of some button i need open some content page which are not part of master page.
What i want is- any conent page should open within the master page means from any content page master page's header and left sliding menu should be easily available to user.
I am tryng to bind master page from content page on runtime but no luck yet. Please help.
====updating my query for better understanding===
1. Sample master details page look like below
[1
Click on item 1 open page 1 with sliding icon on left side of page title
Click on "GO TO PAGE 3" open page 3 with navigation back button. I think as this page is not bind to master page it shows normal back button. Basically i want to replace this navigation back button with "master detail" sliding button in every page those are not part of master page.
Please let me know how to replace navigation back button icon and behavior with master detail sliding button. I know following line of code can be used to open sliding menu but do not know how to hook the back button even.
(App.Current.MainPage as MasterDetailPage).IsPresented = true;

navigation bar not show when i drag to show another page

first i use the PAGGING library
https://github.com/uacaps/PageMenu
i found that it's the problem , when i connect any button to show another controller it it navigate me to that controller but the navigation not shown , for example back button
i try many solutions and non of them work for example i try to make the menu manual but the back button show but not work
i create button and connect to this action
self.navigationController?.popViewControllerAnimated(true)
didn't work
You need to have a pushViewController first. Ensure that you are displaying your viewcontrollers through push.
self.navigationController?.pushViewControllerAnimated(true)
You do not need to code anything to display the previous controller when you have push.

Ordering issue in modal window

I have a problem with a component that loads in to a modal window. I am using the Alpha User Points system and it has a component that gives you a full list of yous site's users. It also gives you the ability to order by username, by points etc. If I use it outside of modal window it works fine. If I use it in to modal window, ordering don't work!!! When I put my mouse over table's headers, outside of modal window gives this...javascript:tableOrdering('aup.referreid','asc','');In to modal window I see this...javascript:tableOrdering('aup.referreid','asc','');?ml=1 Using Firebug, I remove this ?ml=1 and it works into modal also!!! So the question is, why in to modal window gives this ?ml=1, what is this? And how will I remove it?
Well here is the answer... I use the Modalizer extension of nonumber.nl. I was loading my component through modalizer's modal box, this is why I had this issue. So, if anyone use Modalizer to popup components and have the same problem with me, just go to modalizer's Plugin Manager, find the option Convert Links inside Window and disable it!!! But, after this, if you want to add link in to modal window and you don't want to show-up the whole front page but only the component or what ever this is, you have to add at the end of the link this &ml=1.

Resources