After Updating Mvvmcross 5.2 I Have Error Fragment Already Active
Solution 1:
The issue is that you are mixing your methods for presenting in MvvmCross. With MvvmCross 5.x a new prefer way to navigate was introduced using the IMvxNavigationService. For new apps it is suggested that you rather make use of the IMvxNavigationService over the prior ShowViewModel. It is advised that you do not mix the use of the two different ways to navigate as you may get some strange behaviour.
Switching to that IMvxNavigationService which you are already using on the LoginViewModel will solve the exception you are getting.
protectedreadonly IMvxNavigationService _mvxNavigationService;
publicMainViewModel(IMvxNavigationService mvxNavigationService)
{
_mvxNavigationService = mvxNavigationService;
}
publicvoidShowMenu()
{
_mvxNavigationService.Navigate<MenuViewModel>();
}
Additionally, you will want to remove adding HomeFragment to the backstack to prevent seeing a white page when navigation back.
[MvxFragmentPresentation(typeof(MainViewModel), Resource.Id.content_frame)]
publicclassHomeFragment : BaseFragment<HomeViewModel>
See pull request for full details of changes.
Additional notes
Rather than explicitly specifying MvxAppCompatViewPresenter in your Setup which inherits MvxAndroidSetup you can rather inherit from MvxAppCompatSetup which will automatically make use of the MvxAppCompatViewPresenter as well as register additional AndroidViewAssemblies relating to support libraries (see link to which assemblies) and FillTargetFactories for the MvxAppCompatSetupHelper.
Post a Comment for "After Updating Mvvmcross 5.2 I Have Error Fragment Already Active"