When using shell, if you want to programmatically clear and redraw the bottom tabs on a shell page, you can't use Items.Clear to get rid of all the existing ones because it crashes. Investigation suggests that this is because it's trying to set properties on a tab that is no longer there.
The tabs are cleared and you're free to create new ones
Exception and crash
Do you have a sample where the problem happens?, could you attach it?. Thanks in advance!
https://github.com/SFSteve/Xamarin-Demos/tree/master/Xaminals
If you run that then go to the Random page from the flyout menu, you'll get the error.
If it helps, here is another test app to demonstrate the issue.
The crash happens at AppShell.xaml.cs line 29.
Adding an exception is probably not the best solution for this
See comment here
https://github.com/xamarin/Xamarin.Forms/pull/8079#issuecomment-546028951
Most likely the fix for this will be to just throw an exception that Clear isn't supported for Shell
If you clear all the items then Shell has no idea what to display. It's like setting the MainPage on the app to NULL
We have work being done for an IsVisible property which will be the way to change visibility of items. For now I would just add what you are wanting to add then remove what you are wanting to remove
An IsVisible flag would be ideal and solve the actual issue we're having, so it's good to know there's one on the way.
closed by #8215
Hi, This is still broken in IOS, any plans on when this will be fixed?
even when the Tab has multiple ShellItems when I try to Remove the first item "Items.RemoveAt(0);" it still crashes.
Most helpful comment
Edit
Adding an exception is probably not the best solution for this
See comment here
https://github.com/xamarin/Xamarin.Forms/pull/8079#issuecomment-546028951
Edit over
Most likely the fix for this will be to just throw an exception that Clear isn't supported for Shell
If you clear all the items then Shell has no idea what to display. It's like setting the MainPage on the app to NULL
We have work being done for an IsVisible property which will be the way to change visibility of items. For now I would just add what you are wanting to add then remove what you are wanting to remove