我在我的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());
答案 0 :(得分:2)
MvxAndroidViewPresenter
通过Activity
属性公开当前有效CurrentActivity
。
private bool OnPopViewModelHint(PopViewModelHint popViewModel)
{
CurrentActivity?.Finish();
return true;
}