Reputation: 1311
I'm using Visual Studio 2013 and MvvmCross to create an Android application using Portable Class Libraries. When I try and load a second ViewModel based on an action in the first View, an Unhandled Exception is being thrown.
In my first ViewModel, CatalogViewModel, I've got an ICommand called ShowCamera that is supposed to display the second ViewModel, CameraViewModel, when a button in the CatalogView is clicked.
In CatalogView.axml I've bound the button to the ShowCamera method in CatalogViewModel.
Right now the CameraViewModel is just an empty class but it inherits from MvxViewModel just like CatalogViewModel
And there's also a corresponding CameraView.cs and CameraView.axml.
Has anyone else ever encountered this or have any idea why the exception is being thrown. I've tried using a try/catch in the Get to see if I can get any more specific info about the unhandled exception without any luck (the catch block is never hit, the exception is always thrown on the ShowViewModel line).
Thanks in advance.
Upvotes: 0
Views: 307
Reputation: 1311
As Stuart pointed out it his comment, it was the lack of an [Activity] attribute on CameraView that was throwing the exception. The class definition for CameraView should be.
[Activity(Label="View for CameraViewModel")]
public class CameraView : MvxActivity
{
...
}
instead of
public class CameraView : MvxActivity
{
...
}
I initially thought about deleting the whole question out of embarrassment but decided to answer it and leave it here for anyone else who might encounter this situation in their own code.
Upvotes: 3