【发布时间】:2016-12-22 09:09:20
【问题描述】:
我想从 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 表单项目中调用 MyPopupPage.xaml 页面,但不幸的是,当我在调试项目并单击工具栏图像时,出现这样的错误:
System.ArgumentException:类型参数名称:类型未派生 来自 java 类型。
【问题讨论】:
-
您能分享一下您想出的解决方案吗?我的问题有点类似stackoverflow.com/questions/58508566/…
标签: c# xamarin xamarin.android xamarin.forms android-toolbar