devil_coder
devil_coder

Reputation: 1135

Xamarin mvmcross tab navigation between view models

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

First screen in Tab

Second screen

Sceond Screen in Tab

Screen I am seeing

Screen I am seeing when clicking on Next button

Upvotes: 0

Views: 310

Answers (1)

Martijn00
Martijn00

Reputation: 3559

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);

Upvotes: 1

Related Questions