Search code examples
c#xamluwpmvvmcrossuwp-xaml

MvvmCross can't add second xaml view for other device family


In a UWP project you can add a new xaml view with the same name without the class background to create a specific view for a platform, for example mobile.

So I have my general view with code behind class:

PaymentListView.xaml and PaymentListView.xaml.cs.

And I wanted to create a new view for Mobile. So I created a XAML view with the name: PaymentListView.DeviceFamily-Mobile.xaml

Both have the type views:MvxWindowsPage.

Now when I run the application, I get an exception on setup.Initialize:

Problem seen creating View-ViewModel lookup table - you have more than one View registered for the ViewModels: 2*PaymentListViewModel (PaymentListView,PaymentListView)'

Is there a way to solve this or do I have to make a giant Visual Trigger an press both UI's in one XAML?


Solution

  • During creating an example I found the issue.

    I have all my views in a folder views. When I created a new XAML view in that folder the class path was something like this:

    x:Class="MoneyFox.Windows.PaymentListView"

    Therefore it wasn't correctly mapped to the PaymentListView.xaml.cs who has the namespace MoneyFox.Windows.Views.PaymentListView. As soon as I adjusted that, it worked.