1
votes

I have an MVVM Cross application, and I'm trying to figure out why the initial screen isn't showing (this is on WinRT).

The following code looks like it loads the ViewModel MainViewModel:

var setup = new Setup(rootFrame);
setup.Initialize();

var start = Cirrious.CrossCore.Mvx.Resolve<Cirrious.MvvmCross.ViewModels.IMvxAppStart>();
start.Start();

However, the Start method of MainViewModel never gets called. The reason appears to be this error in the output:

Error seen during navigation request to MainViewModel - error KeyNotFoundException: Could not find view for MyApp.PCL.ViewModels.MainViewModel

So, here's my guess as to the problem: it's looking for MyApp.PCL.ViewModels.MainView, Obviously, this doesn't exist. The view is in: MyApp.Views.MainView. Is my assumption correct and, if so, how can I persuade MVVMCross to look in the correct place?

EDIT:

The Setup method is called from the MyApp.Windows WinRT app.

protected override IMvxApplication CreateApp()
{
    return new MyApp.PCL.App();
}

MyApp.PCL is a portable class library that is referenced from MyApp.Windows. MyApp.PCL contains the ViewModels, and MyApp.Windows contains the views.

I have tried to override Start():

public class MainViewModel 
    : MvxViewModel
{

    public override void Start()
    {            
        System.Diagnostics.Debugger.Break();
        base.Start();
    }

but this never gets hit.

1
Shouldn't your view be in MyApp.WinRT.Views? - Casper Skoubo
It would still be a different namespace? - Paul Michaels
By default Mvx WindowsStore looks for views in the entire assembly in which Setup is run. From your question, I've no idea wha's happening - can't see what your project/solution structure is. You could edit your question to provide more detail? Or I guess you could override github.com/MvvmCross/MvvmCross/blob/v3.1/Cirrious/… to debug and step into what's happening in your case. There is some customisation info in github.com/MvvmCross/MvvmCross/wiki/… - Stuart
Thanks for replying so quickly Stuart. I've updated my post. One thing that I didn't mention (I don't believe it's relevant) is that the app is a universal app; however, I have removed the Windows Phone project. - Paul Michaels

1 Answers

1
votes

Massive Doh! here, but I'll post the solution; my view was not using the MvxStoreView, but the standard StoreView.

The solution was to change the view as follows:

 ...
 xmlns:views="using:Cirrious.MvvmCross.WindowsStore.Views"
 ...
<views:MvxStorePage