I have problem for Navigation in my app. I use xamarin.forms how can clean my navigation stack. No use Pop and push. Can I see my full navigation stack ?
You can try this...
public void ResetNavigationStack()
{
if (_navigation != null && _navigation.NavigationStack.Count() > 0)
{
var existingPages = _navigation.NavigationStack.ToList();
foreach (var page in existingPages)
{
_navigation.RemovePage(page);
}
}
}
and BOOOM!!! that nav stack is cleared brotha!
Or if you wanna reset the modal stack
public async Task PopAllModals()
{
Page root = null;
if (_navigation.ModalStack.Count() == 0)
return null;
for (var i = 0; i <= _navigation.ModalStack.Count(); i++)
{
root = await _navigation.PopModalAsync(false);
}
return root;
}
And BOOOM! those modals are gone!