问题
Context: Our team is trying to use Xamarin.Forms (XF) Embedding to slowly convert our project from using Xamarin.Native to XF, for easier maintenance & implementation of features in the future.
The Problem: As you can see in the function parameters on the lines referenced by the links, Xamarin allows you to convert any type of XF Page to a native ViewController in iOS, but it only allows converting a XF ContentPage to a native Fragment in Android.
Importance: This difference plays a major role, because through Xamarin.Native Android, you can't implement a XF NavigationPage. What does that mean? From within Xamarin.Native Android, you can't convert your app to use XF, so you can't call functions like PushAsync or PopAsync.
Added Explanation: You can open NavigationPages on iOS, as you can see in this sample here which allows using functions like PushAsync or PopAsync, by simply doing:
UIViewController user2 = new NavigationPage(new TestPage()).CreateViewController();
So for Android as seen here, currently we can only do this
Android.Support.V4.App.Fragment fragment = new TestPage().CreateSupportFragment(this);
and I was wondering is there a way to do something like this?
Android.Support.V4.App.Fragment fragment = new NavigationPage(new TestPage()).CreateSupportFragment(this);
Question: Has anyone opened a Xamarin.Forms NavigationPage from Xamarin.Android native before? Does anyone know of a workaround that will allow us to use the PushAsync and PopAsync functions?
PS: Here's the Github playground which was a Spike
来源:https://stackoverflow.com/questions/58508566/cannot-open-a-xamarin-forms-page-from-xamarin-android