问题是如何从Android中的Activity导航到xamarin表单我的整个项目都在Xamarin Android中,但我必须调用同一项目中的XAML(xamarin表单)
我尝试了这个. Xamarin.Forms.Application.Current.MainPage.Navigation.PushModalAsync(new zxing_android.Resources.layout.Page2());
还有这个
Intent intent = new Intent(this, typeof(zxing_android.Resources.layout.Page2));
StartActivity(intent);
字符串
在这两种情况下,它都给我一个错误,
x1c 0d1x的数据
如图所示,我正在尝试从Xamarin Android MainActivity打开Page2.axml
谢谢你!
1条答案
按热度按时间jvlzgdj91#
首先,我不建议你在xamarin.android项目中使用xaml,它应该在跨平台项目中使用。
在xamarin.android项目中,如果你想显示contentpage,你可以使用refer to the xamarin.forms项目并使用
FormsAppCompatActivity
来呈现contentpage。1.在你的项目中安装
Xamarin.Forms
nuget包。我安装了最新版本,并将Xamarin.Google.Android.Maerial
nuget包更新到最新版本。1.在项目中创建
Xamarin.Forms.Application
:App.xaml:
字符串
App.cs:
型
**注意:**我创建app.cs时,它告诉我找不到MainPage和Resource。关闭并重新打开项目可以解决此问题。
1.在
FormsAppCompatActivity
中加载Xamarin.Forms.Application
:型
1.转到主活动中的内容页:
型
我的项目结构:
的数据