FreshMvvm icon indicating copy to clipboard operation
FreshMvvm copied to clipboard

CoreMethods.PopToRoot not working in UWP

Open marcorm opened this issue 9 years ago • 5 comments
trafficstars

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

marcorm avatar May 13 '16 16:05 marcorm

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.

oddbear avatar Jun 08 '16 09:06 oddbear

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.

jessejiang0214 avatar Jun 09 '16 03:06 jessejiang0214

what is the status today? can we not fix it?

EmilAlipiev avatar Feb 10 '17 00:02 EmilAlipiev

@EmilAlipiev You said you were having this issue in Android as well (from this comment). What version of Android are you using?

Ebsan avatar Feb 10 '17 23:02 Ebsan

await CoreMethods.PopPageModel(true, true); await CoreMethods.PopToRoot(true);

if your Page is a modal then you should remove the modal first then popToRoot.

joristackaert avatar Jan 03 '20 23:01 joristackaert