Xamarin mvmcross tab navigation between view models

南笙酒味 提交于 2019-12-12 03:35:49

问题


I have two screens which are linked to two tab buttons

  1. Name
  2. Duration

I would like tab to move to second button when I click Next button. In my view model this is my command for Next Button

Here is my code sample

public IMvxCommand NextCommand
{
    get
    {
        return new MvxCommand(() => ShowViewModel<RecyclerViewModel>());
    }
}

Rather than tab moving to next tab second view is opening in full screen.

Screens attached

First screen

Second screen

Screen I am seeing


回答1:


I this situation i would not use the MvvmCross ViewModel navigation, because to use that you probably have to create a custom presenter.

What you can do is just add a button click in the Activity or Fragment itself and use the following code:

var viewPager = view.FindViewById<ViewPager>(Resource.Id.viewpager);
viewPager.SetCurrentItem(1, true);


来源:https://stackoverflow.com/questions/35407071/xamarin-mvmcross-tab-navigation-between-view-models

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!