Wilton
Wilton

Reputation: 226

MVVMCross - Navigate ViewModel

When I try to open a new viewmodel I'm receiving the following error:

Failed to load ViewModel for type EasyBudget.Core.ViewModels.GridCategoryViewModel from locator MvxDefaultViewModelLocator

It´s also shows:

No symbols found.

And shows that cannot find or open the PDB file.

My viewmodel:

public class HomeViewModel 
    : MvxViewModel
{
    private Cirrious.MvvmCross.ViewModels.MvxCommand _listCommandCategory;

    public System.Windows.Input.ICommand ListCommandCategory
    {
        get
        {
            _listCommandCategory = _listCommandCategory ?? new Cirrious.MvvmCross.ViewModels.MvxCommand(DoListCategory);
            return _listCommandCategory;
        }
    }

    private void DoListCategory()
    {
        ShowViewModel<GridCategoryViewModel>();
    }   
}

And my other viewmodel:

public partial class GridCategoryView : MvxPhonePage
{
    public GridCategoryView()
    {
        InitializeComponent();
    }
}

Does anyone knows what may I be forgeting?

Best regards

Wilton Ruffato Wonrath

Upvotes: 1

Views: 677

Answers (2)

Egor Samets
Egor Samets

Reputation: 109

Perhaps, you forgot about adding ViewModel type to your generic MvxPhonePage. Try this:

public partial class GridCategoryView : MvxPhonePage<GridCategoryViewModel>

Upvotes: 0

Stuart
Stuart

Reputation: 66882

I believe the problem will most likely be somewhere in the construction of the ViewModel:

  • perhaps the constructor itself isn't public?
  • perhaps one or more of the parameters for the constructor couldn't be found?
  • perhaps some code inside the constructor has thrown an exception

Where you posted 'my other viewmodel' you actually posted code only for your other view. Can you post the code for the ViewModel that accompanies that view?


If you enable your debugger to break on all Exceptions, then this will possibly help you to find the problem that occurs during loading (inside https://github.com/slodge/MvvmCross/blob/v3/Cirrious/Cirrious.MvvmCross/ViewModels/MvxDefaultViewModelLocator.cs).


If you want to a pdb for debugger symbols, then these can be found inside the folders of http://github.com/slodge/MvvmCross-Binaries - inside the VS2012/Release folders. We are also currently trying to work out how to distribute these via SymbolSource.org (first got the request/suggestion this week)


Finally, if you want to see trace from a Windows build and are using the release packages from nuget then you can do this by overriding CreateDebugTrace() in your Setup.cs file - e.g. try:

    protected override IMvxTrace CreateDebugTrace()
    {
        return new MvxDebugTrace();
    }

This will also allow you to add some debug trace to your Core code if you want to using:

    Mvx.Trace(format, args...)
    Mvx.Warning(format, args...)
    Mvx.Error(format, args...)

Upvotes: 1

Related Questions