FreshMvvm
FreshMvvm copied to clipboard
CoreMethods.PopToRoot not working in UWP
Calling await CoreMethods.PopToRoot(true/false) does nothing in UWP Project.
For the moment any workaround would be very appreciated.
Thx for your great work!
EDIT: I'm using FreshMvvm version 2.0.1 and Xamarin.Forms 2.1.0.6529 EDIT 2: Now, Xamarin Forms to 2.2.0.31 and FreshMvvm to 2.1.0, same problem
What about:
var navigationService = FreshIOC.Container.Resolve<IFreshNavigationService>(CurrentNavigationServiceName) as NavigationPage;
navigationService.Navigation.PopToRootAsync()
If you still got the problem, then this would probably be a Xamarin.Forms bug. You might try something like:
public bool SendClearNavStackCommand()
{
try
{
var navigation = NavigationService.Navigation;
var stack = navigation.NavigationStack.ToList();
for (int i = 1; i < stack.Count; i++)
{
navigation.RemovePage(stack[i]);
}
return true;
}
catch
{
//Could create a new navigation stack here, and dump the old one.
return false;
}
}
Or just se if Xamarin.Forms.Device.BeginInvokeOnMainThread would help.
Hi Marcorn,
This is a bug of Xamarin.Forms. https://bugzilla.xamarin.com/show_bug.cgi?id=31809 We just call Xamarin.Forms.NavigationPage.PopToRootAsync in FreshMvvm, so it cannot work currently. But It will be fixed in the future.
what is the status today? can we not fix it?
@EmilAlipiev You said you were having this issue in Android as well (from this comment). What version of Android are you using?
await CoreMethods.PopPageModel(true, true); await CoreMethods.PopToRoot(true);
if your Page is a modal then you should remove the modal first then popToRoot.