0
votes

Based on MvvmCross, I need to navigate MainViewModel to TestViewModel, here is my code and its not working

MainViewModel:

 //Command_SJCJ is a button in MainPage
  public IMvxCommand Command_SJCJ
        {
            get
            {
                return new MvxCommand(() =>
                    _navigationService.Navigate<TestViewModel>());
            }
        }

TestViewModel:

 public class TestViewModel:MvxViewModel
            {
                private IMvxNavigationService _navigationService;
                public TestViewModel(IMvxNavigationService navigation)
                {
                    _navigationService = navigation;
                }
            }
        }

TestPage.xaml:

 <?xml version="1.0" encoding="utf-8" ?>
        <views:MvxWindowsPage xmlns="http://xamarin.com/schemas/2014/forms"
                              xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
                              xmlns:controls="clr-namespace:Esri.ArcGISRuntime.UI.Controls;assembly=Esri.ArcGISRuntime"
                              xmlns:views="using:MvvmCross.Uwp.Views"
                              x:Class="nsc.hby.Survey.UWP.Pages.TestPage">
            <views:MvxWindowsPage.Content>
                <controls:MapView/>
            </views:MvxWindowsPage.Content>
       </views:MvxWindowsPage>
1
Post your code here to give help...Shiwanka Chathuranga
thanks.i almost forgot it.user8880895
which mvvmcross version your using?Shiwanka Chathuranga
what i have understand here , you need to navigate MainViewModel to TestViewModel?Shiwanka Chathuranga
Yes,I want to navigate MainViewModel to TestViewModel. I have defined TestPage as a MvxContentPage, and there's no problem, but when I define it as MvxWindowsPage, this page will not appear.user8880895

1 Answers

0
votes

This is how your navigation work in mvvmcross 5

public class MainViewModel : MvxViewModel
{
    public ICommand GoCommand
    {
        get
        {
            return new MvxCommand(() => ShowViewModel<TestViewModel>();
        }
    }
}



public class TestViewModel : MvxViewModel
{
}