无法打开Xamarin.Forms“页面"来自Xamarin.Android [英] Cannot open a Xamarin.Forms "Page" from Xamarin.Android
问题描述
上下文::我们的团队正在尝试使用Xamarin.Forms
(XF)
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.
问题:您可以在链接所引用的行的函数参数中看到,Xamarin允许您将任何类型的XF Page
转换为ViewController href ="https://github.com/xamarin/Xamarin.Forms/blob/master/Xamarin.Forms.Platform.Android/AppCompat/PageExtensions.cs#L75" rel ="nofollow noreferrer"> iOS ,但它仅允许在Fragment
. cs#L8"rel =" nofollow noreferrer> Android .
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.
重要性:这种差异起主要作用,因为通过Xamarin.Native Android
,您不能实现XF NavigationPage
.那是什么意思?在Xamarin.Native Android内部,您无法将应用程序转换为使用XF,因此无法调用PushAsync
或PopAsync
之类的函数.
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
.
添加的解释:您可以在 iOS,如您在此示例中所见,它只需执行以下操作即可使用PushAsync
或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);
问题:以前有人从Xamarin.Android本机打开Xamarin.Forms NavigationPage
吗?有谁知道一种允许我们使用PushAsync和PopAsync函数的解决方法?
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:这是 Github 操场,它是斯派克 >
推荐答案
目前该API尚无法实现.
As the API currently stands, it is not possible to implement.
我确实创建了一个 GitHub问题,所以如果可以的话并给它竖起大拇指来创建一种可能的方法,那太好了
I did create a GitHub issue, so if you could go there and give it a few thumbs up to create a possible way, that would be great
这篇关于无法打开Xamarin.Forms“页面"来自Xamarin.Android的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!