It is not possible to await the navigation result in viewmodel A when navigating on viewmodel B, if the viewmodel B navigate again to viewmodel C.
If I navigate from the viewmodel A to the viewmodel B and I await the result of the viewmodel B, when the viewmodel B navigates to another viewmodel C, the navigation to the viewmodel C starts, buti the await from the viewmodel B in the viewmodel A returns with unexpected null TResult.
The await in the viewmodel A must await the viewmodel B to Close explicitly.
Create an application with 3 viewmodels.
Version: 6.2.1
Platform:
I noticed same bug in my app, as soon as you navigate from ViewModel B to C, B returns the result to A, in this case null.
Configuration
Version: 6.2.1
@symibsoft , @agarciasempere , I've found a workaround. You can just use MvxNavigationViewModel instead of MvxViewModel and it will work. But be aware, it returns null in case of back button press.
@xyashapyx, thank you for the response. I tried your solution but it does not work for me. The issue is the same.
@symibsoft have you changed just one viewModel base class or base class of all view models in your tree?
@xyashapyx, I changed all my viewmodels in order to inherit from MvxNavigationViewModel.
I have a base viewmodel class like this:
public abstract partial class BaseScreenNotify : MvxNavigationViewModel
//with this constructor
public BaseScreenNotify(IMvxLogProvider logProvider, IMvxNavigationService navigationService) : base(logProvider, navigationService)
All my viewmodels are inheriting from that base class.
@xyashapyx, Didn't work for me either, just tried same case as @symibsoft did. Same problem persist. I even noticed on Android that if you put the app on background viewmodel returns null too and you are not able to return result anymore.
@symibsoft , @agarciasempere, I don't know if it is a case but all my commands that are invoking navigation declared like:
public IMvxAsyncCommand NavigateCommand => new MvxAsyncCommand(NavigateMethod, allowConcurrentExecutions: true);
Can you try this also?
Hi!
Thank you @xyashapyx but your solution did not solve the issue.
I found a solution but only on android platform.
Before I had the MainApplication class inheriting from MvxAppCompatApplication.
I changed that in order to inherit from MvxAndroidApplication and on android I solved the issue.
I can't find a solution for the UWP implementation. Now I'm inheriting my UWP app class from MvxApplication.
@symibsoft
I found one more workaround:)
you can override your 2nd view model ViewDestroy like
public override void ViewDestroy(bool viewFinishing = true)
{
base.ViewDestroy(false);
}
@symibsoft
I found one more workaround:)
you can override your 2nd view model ViewDestroy likepublic override void ViewDestroy(bool viewFinishing = true) { base.ViewDestroy(false); }
Save me day, works perfectly for me.
Thanks.
@symibsoft
I found one more workaround:)
you can override your 2nd view model ViewDestroy likepublic override void ViewDestroy(bool viewFinishing = true)
{
base.ViewDestroy(false);
}
Also works for me. Thanks!
Thank you guys, I solved with your suggestion.
The viewdestroy override solved the problem in windows platform. I leave the android platform without this override.
Most helpful comment
@symibsoft
I found one more workaround:)
you can override your 2nd view model ViewDestroy like