如何将 Xamarin Forms Shell 集成到 MvvmCross 设置中 [英] How to integrate Xamarin Forms Shell into an MvvmCross setup

查看:58
本文介绍了如何将 Xamarin Forms Shell 集成到 MvvmCross 设置中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我打算将 Xamarin Forms 与 MvvmCross 结合使用.

根据他们的教程App.cs文件需要添加到项目中:

 公共类 App : MvxApplication{公共覆盖无效初始化(){//Mvx.IoCProvider.RegisterType();RegisterAppStart();}}

那么原来的App.xaml.cs就可以作为MvxFormsApplication类:

公共部分类 FormsApp : MvxFormsApplication{公共 FormsApp(){初始化组件();//DependencyService.Register();MainPage = new AppShell();}}

不幸的是 AppShell.xamlAppShell.xaml.cs 文件添加了很多必要的 UI 设置代码,它最初是由 App.xaml 添加的.cs:

 MainPage = new AppShell();

由于 MvvmCross 接管了整个初始化,我不知道如何集成弹出和其他基本 UI 代码.

如果我像这样将它们放在主视图中:

<FlyoutItem Title=关于"图标=icon_about.png"><ShellContent Route="AboutPage";ContentTemplate="{DataTemplate local:AboutPage}";/></FlyoutItem>

我遇到了一些层次错误:

<块引用>

内容不支持FlyoutItem"类型的值

那么我应该如何将 Shell 集成到 MvvmCross 应用程序中?

解决方案

MvvmCross 目前不支持 Xamarin.forms.Shell.

有关更多信息,请查看其 GitHub 存储库中的相关问题.>

I intend to use Xamarin Forms with MvvmCross.

According to their tutorial, the App.cs file is required to be added to the project:

 public class App : MvxApplication
  {
    public override void Initialize()
    {
      //Mvx.IoCProvider.RegisterType<ICalculationService, CalculationService>();

      RegisterAppStart<MainViewModel>();
    }
  }

Then the original App.xaml.cs can be used as the MvxFormsApplication class:

public partial class FormsApp : MvxFormsApplication
{
  public FormsApp()
  {
    InitializeComponent();
    //DependencyService.Register<MockDataStore>();
    MainPage = new AppShell();
  }
}

Unfortunately the AppShell.xaml and AppShell.xaml.cs files add a lot of necessary UI setup code and it was originally added by the App.xaml.cs:

 MainPage = new AppShell();

As MvvmCross takes over the entire initialization, I don't know how to integrate the flyout and other basic UI code.

If I put them inside the main view like this:

<views:MvxContentPage.Content>
  <FlyoutItem Title="About" Icon="icon_about.png">
    <ShellContent Route="AboutPage" ContentTemplate="{DataTemplate local:AboutPage}" />
  </FlyoutItem>

I get some hiearchy error:

Content does not support values of type 'FlyoutItem'

So how should I integrate the Shell into the MvvmCross app?

解决方案

MvvmCross does not support Xamarin.forms.Shell as of now.

For more information, check the related issue at their GitHub repository.

这篇关于如何将 Xamarin Forms Shell 集成到 MvvmCross 设置中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆