我有3个ViewModels。 FirstViewModel,SecondViewModel和ThirdViewModel。
我想在FirstViewModel中单击一个按钮,然后它将打开SecondViewModel。在打开SecondViewModel之后,没有任何用户交互,将通过代码打开ThirdViewModel。
我无法让ThirdViewModel自动打开。
using Cirrious.MvvmCross.ViewModels;
namespace PortableClassLibrary1.ViewModels
{
public class FirstViewModel
: MvxViewModel
{
private string _hello = "Hello MvvmCross 1";
public string Hello
{
get { return _hello; }
set { _hello = value; RaisePropertyChanged(() => Hello); }
}
private MvxCommand _goSecondCommand;
public System.Windows.Input.ICommand GoSecondCommand
{
get
{
_goSecondCommand = _goSecondCommand ?? new Cirrious.MvvmCross.ViewModels.MvxCommand(DoGoSecond);
return _goSecondCommand;
}
}
private void DoGoSecond()
{
ShowViewModel<SecondViewModel>();
}
}
}
using Cirrious.MvvmCross.ViewModels;
namespace PortableClassLibrary1.ViewModels
{
public class SecondViewModel
: MvxViewModel
{
private string _hello = "Hello MvvmCross 2";
public string Hello
{
get { return _hello; }
set { _hello = value; RaisePropertyChanged(() => Hello); }
}
private MvxCommand _goThirdCommand;
public System.Windows.Input.ICommand GoThirdCommand
{
get
{
_goThirdCommand = _goThirdCommand ?? new Cirrious.MvvmCross.ViewModels.MvxCommand(DoGoThird);
return _goThirdCommand;
}
}
private void DoGoThird()
{
ShowViewModel<ThirdViewModel>();
}
public override void Start()
{
base.Start();
DoGoThird();
}
}
}
using Cirrious.MvvmCross.ViewModels;
namespace PortableClassLibrary1.ViewModels
{
public class ThirdViewModel
: MvxViewModel
{
private string _hello = "Hello MvvmCross 3";
public string Hello
{
get { return _hello; }
set { _hello = value; RaisePropertyChanged(() => Hello); }
}
}
}