-1

I have my UWP Application inherited from Base class, which inherits from MvxApplication<Setup, CoreApp>:

public sealed partial class App : WindowsApplication
{
    public App()
    {
        InitializeComponent();
    }
}

public class WindowsApplication : MvxApplication<Setup, CoreApp>
{
}

public class Setup : MvxWindowsSetup<CoreApp>
{
    public override IEnumerable<Assembly> GetViewAssemblies()
    {
        // need to do this as otherwise I receive the message that corresponding view to view model is not found
        var assemblies = base.GetViewAssemblies().ToList();
        assemblies.Add(typeof(Forms.App).Assembly);
        return assemblies;
    }
}

However, when launching it, receiving the following error message:

The type MvxContentPagePresentationAttribute is not configured in the presenter dictionary

As I understand, all that is not proper way to launch Xamarin.Forms MvvmCross application, as UWP App and Setup should be inherited from something like MvxFormsApplication and MvxFormsWindowsSetup<CoreApp, Forms.App> respectively (to have Xamarin.Forms app properly initialized).

But:

  • MvxFormsApplication is not generic and doesn't provide ability of passing Forms-generic setup.
  • even if I inherit the App from MvxFormsApplication and use this.RegisterSetupType<MvxFormsWindowsSetupInheritor>();, Visual Studio compiler never allows me to compile the project because of some weird error message (something like The name “WindowsApplication” does not exist in the namespace “…”) (this might be some issue of Visual Studio, but I have VS 15.7 version, which expects the code to work (again, MvvmCross declares they support UWP and XF)).

So, from my understanding, if there is Xamarin.Forms app, there must be also some way of passing actually Xamarin.Forms App class to the UWP App class initialization.

MvvmCross, again, stands for UWP and Xamarin.Forms support, but I can't see any clear example of the way to setup such type of application.

MvvmCross documentation as always is quite "modest". There are some instructions about setting up MvvmCross UWP app as well as setting up MvvmCross XF iOS/Android, but the only word about MvvmCross XF UWP is:

You are now free to place your custom renderers in a different assembly. All you have to do to make it work is to add your assembly to the Setup.ViewAssemblies collection. (in official website docs) (which is still sounds weird, as iOS and Android versions don't need that additional code, which makes me think that such (current) documentation isn't quite actualized)

and

  • UWP, WPF
  • Extend App from MvxApplication. ( App : MvxApplication { } )

from MvvmCross.Forms package readme.txt file, when all other platforms, again, expect inheritance for the app classes from MvxForms*-based ones.

MvvmCross guys, any thoughts on that?

Agat
  • 4,577
  • 2
  • 34
  • 62
  • Have you checked this [blog](https://medium.com/@martijn00/using-mvvmcross-with-xamarin-forms-part-1-eaee5815bb8c). – CoCaIceDew Jun 12 '18 at 08:02
  • I am surely aware of this blog, as it's one of not many others, which provide more specific information than even MvvmCross official docs do. However, I see no relevance there to my question: 1. The latest article date is a year ago (MvvmCross 6.0 released just recently); 2. That article doesn't refer UWP at all; 3. MvvmCross 6.0 packages don't even include Starter Pack, which also mentioned there, as well as the last update of mentioned XabluCross was done a year ago (far away from recent Xamarin.Forms 3.0 release). Please let me know if I missed announced "Part 2" (etc.) of that article! – Agat Jun 12 '18 at 19:51

1 Answers1

0

When I set up a new Xamarin.Forms project, I always follow the Playground sample in the MvvmCross GitHub as this example evolves along with the API and is always up-to-date, as it is part of the MvvmCross solution, so any commits need to preserve its functionality. So if you want to see how everything should look in a minimal UWP + Xamarin.Forms project see the Playground.Forms.UI and Playground.Forms.Uwp projects in the linked folder.

Martin Zikmund
  • 38,440
  • 7
  • 70
  • 91