【问题标题】:MvvmCross - navigation with custom objectsMvvmCross - 使用自定义对象导航
【发布时间】:2015-03-25 05:49:20
【问题描述】:

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

【问题讨论】:

    标签: xamarin mvvmcross


    【解决方案1】:

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

        /// <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)
        {
        }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-10-12
      • 1970-01-01
      • 2023-03-04
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多