Search code examples
c#xamarin.formsmvvmcross

How to integrate Xamarin Forms Shell into an MvvmCross setup


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?


Solution

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

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