如何使用演示提示完成活动?

时间:2017-12-26 10:22:10

标签: xamarin.android mvvmcross

我在我的Xamarin.Android应用程序中使用MvvmCross。我希望能够通过演示提示完成当前活动。以下是我的观点演示者:

public class ViewPresenter : MvxAndroidViewPresenter
{
    public ViewPresenter(IEnumerable<System.Reflection.Assembly> assemblies) : base(assemblies)
    {
        AddPresentationHintHandler<PopViewModelHint>(OnPopViewModelHint);
    }

    private bool OnPopViewModelHint(PopViewModelHint popViewModel)
    {
        // how to finish current activity?
        return true;
    }
}

从我的视图模型:

ChangePresentation(new PopViewModelHint());

1 个答案:

答案 0 :(得分:2)

MvxAndroidViewPresenter通过Activity属性公开当前有效CurrentActivity

private bool OnPopViewModelHint(PopViewModelHint popViewModel)
{
    CurrentActivity?.Finish();
    return true;
}