MVVMCross - ShowViewModel not working?

August 10, 2014

I thought I’d jot this down, as it had me for a short while. Imagine that you have a line of code that looks like this:


But nothing happens when you call it.

The Output Window

The output window is definitely your friend with MVVMCross; it may say something like this:

mvx:Diagnostic: 36.44 Error seen during navigation request to MyViewModel - error KeyNotFoundException: Could not find view for MyApp.PCL.ViewModels.MyViewModel at Cirrious.MvvmCross.Views.MvxViewsContainer.GetViewType(Type viewModelType) at Cirrious.MvvmCross.WindowsStore.Views.MvxStoreViewPresenter.Show(MvxViewModelRequest request)

So, what’s the problem?

Some things to check: firstly, check that you are using an MVVMCross view; that is, for example, in Windows 8, you need your page to inherit from MvxStorePage, not Page:

[sourcecode language=“XML”] Conclusion

Nothing here that you won’t see on one of Stuart Lodge’s tutorials, and probably a good handful of SO questions. So now it’s here as well.

Profile picture

A blog about one man's journey through code… and some pictures of the Peak District

© Paul Michaels 2024