MvvmCross - 使用自定义对象导航

MvvmCross - navigation with custom objects

我已按照此 link 中的步骤操作 Passing complex navigation parameters with MvvmCross ShowViewModel

我实现了 IMvxJsonConverter 的一个实例,并注册了它。这是我的视图模型代码

 public class AccountDetailsViewModel : BaseViewModel<AccountDetailsNav>
{


    private readonly Repository.AccountsRepository _accounts;
    Account _fullAccount;
    public AccountDetailsViewModel(Repository.AccountsRepository accounts)
    {
        _accounts = accounts;
    }

    protected override void RealInit(AccountDetailsNav parameter)
    {
        //stuff
    }

我尝试过通过字符串传递简单类型,这是我用来导航到视图模型的代码

   Mvx.RegisterSingleton<Repository.AccountsRepository>(() =>
        {
            return _accounts;
        });


        ShowViewModel<AccountDetailsViewModel>(nav);

但它似乎从未出现在我的视图模型方法中或填充我的数据,而且我终其一生都无法弄清楚原因。数据序列化很好,我什至尝试了空白构造函数无济于事..我只是想不通为什么它没有达到 realinit

K 我发现了问题,当添加一个新视图时,我未能在视图后面的代码中删除此方法,因此导致我的视​​图模型为空并且从未达到我的断点

    /// <summary>
    /// Invoked when this page is about to be displayed in a Frame.
    /// </summary>
    /// <param name="e">Event data that describes how this page was reached.
    /// This parameter is typically used to configure the page.</param>
    protected override void OnNavigatedTo(NavigationEventArgs e)
    {
    }