Hello,
The problem is having an event or something to be able to check, and then prevent the tab switch.
You can check the tab switch operation by creating custom TabBar, then override the OnPropertyChanged
method. Then use this custom tabbar in your AppShell.xaml.
public class MyTab : TabBar
{
protected override void OnPropertyChanged([CallerMemberName] string propertyName = null)
{
if (propertyName == "CurrentItem")
{
int index = this.Items.IndexOf(this.CurrentItem);
if(index == 0)
{
}
if(index == 1)
{
}
}
}
}
But I cannot find a method to prevent the tab switch. You can add a feature request in the MAUI Github page.
Best Regards,
Leon Lu
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.