mvvmcross xamarin android活动显示奇怪的行为

时间:2016-02-11 10:54:48

标签: android android-activity xamarin mvvmcross

我有两个活动,比如

[Activity(Label = "View for FirstViewModel", MainLauncher = true)]
public class FirstView : MvxActivity
{
    protected override void OnCreate(Bundle bundle)
    {
        base.OnCreate(bundle);
        SetContentView(Resource.Layout.FirstView);
    }
}

[Activity(Label = "View for SecondViewModel", MainLauncher = false)]
public class SecondView : MvxActivity
{
    protected override void OnCreate(Bundle bundle)
    {
        base.OnCreate(bundle);
        SetContentView(Resource.Layout.SecondView);
    }
}

和两个ViewModels

 public class FirstViewModel 
    : MvxViewModel
{
    private string _hello = "Hello MvvmCross 1";

    public FirstViewModel()
    {

    }

    public string Hello
    { 
        get { return _hello; }
        set { _hello = value; RaisePropertyChanged(() => Hello); }
    }

    public ICommand Next
    {
        get
        {
            return new MvxCommand(() => ShowViewModel<SecondViewModel>());
        }
    }
}

 public class SecondViewModel : MvxViewModel
{
    public SecondViewModel()
    {

    }

    private string _hello = "Hello MvvmCross 2";

    public string Hello
    {
        get { return _hello; }
        set { _hello = value; RaisePropertyChanged(() => Hello); }
    }

    public ICommand Back
    {
        get
        {
            return new MvxCommand(() => ShowViewModel<FirstViewModel>());
        }
    }

}

我只是尝试两次在它们之间来回切换。后退步骤不起作用。记录看起来对我好。使用与WPF项目相同的VM工作正常。那么机器人活动的问题是什么?

提前致谢!

MH

0 个答案:

没有答案