MvvmCross - 使用自定义对象进行导航

时间:2015-03-25 05:49:20

标签: xamarin mvvmcross

我已按照此链接中的步骤操作 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
    }

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

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


        ShowViewModel<AccountDetailsViewModel>(nav);

但它似乎永远不会到达我的视图模型方法或填充我的数据,我不能为我的生活找出原因。数据序列化很好,我甚至尝试过空白构造函数无济于事。我只是无法弄清楚为什么它没有达到现实

1 个答案:

答案 0 :(得分:0)

K我发现了这个问题,在添加新视图时我无法在视图后面的代码中删除此方法,因此导致我的viewmodel为null并且从不命中我的断点

    /// <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)
    {
    }
相关问题