我希望从Xamarin Android项目中打开Xamarin表单页面。在Android项目中,我创建了工具栏项图像,在其中调用事件以从Xamarin表单项目打开页面。
这是我的MainActivity.cs工具栏图像项实现:
public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsApplicationActivity
{
private IMenu CurrentMenu { get; set; }
private ImageView imgSmallC { get; set; }
public override bool OnCreateOptionsMenu(IMenu menu)
{
ActionBar.DisplayOptions = ActionBarDisplayOptions.HomeAsUp | ActionBarDisplayOptions.ShowCustom | ActionBarDisplayOptions.ShowTitle | ActionBarDisplayOptions.ShowHome;
LayoutInflater inflater = (LayoutInflater)ActionBar.ThemedContext.GetSystemService(LayoutInflaterService);
View customActionBarView = inflater.Inflate(Resource.Layout.actionbar_custom_view_done, null);
imgSmallC = (ImageView)customActionBarView.FindViewById<ImageView>(Resource.Id.ImgSmallC);
imgSmallC.Click += (object sender, EventArgs args) =>
{
StartActivity(typeof(MyPopupPage));
};
return base.OnCreateOptionsMenu(menu);
}
}
在StartActivity中,我从Xamarin Forms项目调用MyPopupPage.xaml页面。但是,不幸的是,当我调试项目并单击工具栏图像时,会出现以下错误:
参数异常:类型参数名称:Type未从java类型派生。