Custom Navigation Using Xamarin.Forms

Im working on an application for Android and iOS, which requires some flexibility for one or two views. That's why we created and implemented a service that translated the basic list of objects into the user interface for iOS and Android. But now that Xamarin.Forms has been released, we decided to replace our service with what Xamarin provides. I was able to create views using Xamarin.Forms, which resulted in more convenient and smooth page management. But my problem is its navigation. Here is a small example of what I would like to achieve:

enter image description here

I want my application to start work starting with a custom snippet. After clicking the button on this snippet, I would like the page that I created using the Xamarin.Forms api to be added to my current navigation stack! After the user has finished the Xamarin.Forms page, moves to the second user fragment, all that does not break the navigation loop. Does anyone know how I can achieve this?

For iOS developers: replace Activity with NavigationController and Fragment with ViewController

+6
source share
2 answers

Check out CarouselPage for the Xamarin.Forms proprietary approach. This doesn't sound like what you need, but you can also look at its source code and possibly do your own rendering yourself.

You can also take a look at MVVM

As for the simplified / hacker way, you have to make a button on each page, and when the button is clicked, do Navigation.PushModalAsync(nextPage) - there will no longer be a "<Back" button, you may need to implement it yourself if you need it .

+2
source

If by your value " current navigation stack " is used to use the built-in navigation of each platform, remember that you do not need to use Xamarin.Forms "and functions such as PushAsync .

If you prefer to do Navigation with code specific to each platform, you can do it the same way as in normal mode. Just create your own stubs in each specific project on the platform and customize the contents of Xamarin.Forms for each page from a common project.

On each separate page dedicated to each platform (Activity / UIView / PhoneApplicationPage), you can configure the Action <> call on the Xamarin.Forms common page to help navigate or, alternatively, intercept a custom event that rises from the Xamarin page. Forms ** back to a specific platform dummy page so you can navigate from there.

As Stan said, there will be no back button, so you will likely have to do this yourself.

+2
source

Source: https://habr.com/ru/post/974034/


All Articles