基于MvvmCross,我需要将MainViewModel导航到TestViewModel,这是我的代码,它不能正常工作
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>
答案 0 :(得分:0)
这就是导航在mvvmcross 5中的工作方式
public class MainViewModel : MvxViewModel
{
public ICommand GoCommand
{
get
{
return new MvxCommand(() => ShowViewModel<TestViewModel>();
}
}
}
public class TestViewModel : MvxViewModel
{
}