Issue
I have a Xamarin Forms application, which has 2 buttons on the toolbar. Currently I'm using FreshMVVM (and it's navigation). I want to load pages without putting them into the navigation. I do not want to have the 'back' button on the toolbar, also I do not want the user return the last page.
Here's how I push a page currently:
CoreMethods.PushPageModel<FirstChoicePageModel>();
I tried to push as a modal, but that way the toolbar buttons does not work until I press back. Should I make new navigation containers and switch to them if I push the buttons?
Solution
It's been a little while since I've used FreshMVVM, but if I recall correctly, you have 2 options:
- If you want to completly reset the nav stack, you can do
CoreMethods.PushPageModelWithNewNavigation<FirstChoicePageModel>(); - If you want to keep the nav stack, you can set
NavigationPage.SetHasBackButton(this, false);in the code behind of the view.
For both of these options, it may necessary to intercept the back button on Android. In the code behind there is an overrideable method:
protected override bool OnBackButtonPressed()
{
return true; // prevent Xamarin.Forms from processing back button
}
Answered By - Andrew
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.