TabbedPage selectedItem doesn't change when change tab programmatically to tab in "More"

TRAN HOANG LONG 11 Reputation points
2021-05-18T07:48:04.017+00:00

Hi everybody,
I am working on a TabbedPage which has 6 tabs.

<TabbedPage xmlns="http://xamarin.com/schemas/2014/forms"  
            xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"  
            xmlns:tabs="clr-namespace:TabbedPageIssue"  
            xmlns:android="clr-namespace:Xamarin.Forms.PlatformConfiguration.AndroidSpecific;assembly=Xamarin.Forms.Core"  
            android:TabbedPage.ToolbarPlacement="Bottom"  
            android:TabbedPage.IsSwipePagingEnabled="False"  
            android:TabbedPage.BarSelectedItemColor="#F79320"  
            android:TabbedPage.BarItemColor="#B1B2B3"  
            x:Class="TabbedPageIssue.MainPage">  
    <tabs:Tab1 Title="Tab1"/>  
    <tabs:Tab2 Title="Tab2"/>  
    <tabs:Tab3 Title="Tab3"/>  
    <tabs:Tab4 Title="Tab4"/>  
    <tabs:Tab5 Title="Tab5"/>  
    <tabs:Tab6 Title="Tab6"/>  
  
</TabbedPage>  

97424-screenshot-1621323149.png

In my app, I want to have a button to direct the app to a tab "inbox" in the "More" part with this code:

private void Button_Clicked(object sender, EventArgs e)  
        {  
            var mainPage = this.Parent as TabbedPage;  
            mainPage.CurrentPage = mainPage.Children[4];  
        }  

When i click the button to change tab, the View changes but the "More" tab is not selected, and if i click on tab1, the view of tab 5 doesn't disappear.

97347-screenshot-1621323697.png

This seems to be a bug of TabbedPage. Everybody has any idea to fix this problem.

Xamarin
Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,296 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Cole Xia (Shanghai Wicresoft Co,.Ltd.) 6,751 Reputation points
    2021-05-19T02:40:50.84+00:00

    Hello,

    Welcome to Microsoft Q&A!

    I did reproduce the problem , and I'm sure this is a potential issue .

    Because if we set CurrentPage as the first 4 items , it works fine , but the tab does not change when the index is greater than 4.

    Only we manually click on the items in more dialog so that the selected tab get changed , but it does not work just with the code CurrentPage = tabbedpage.Children[4];

    Consider raising issue on github : https://github.com/xamarin/Xamarin.Forms/issues .

    Best Regards,
    Cole Xia


    If the response is helpful, please click "Accept Answer" and upvote it.
    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.

    0 comments No comments

  2. karthik madathiparambhil 0 Reputation points
    2023-02-08T02:46:19.4533333+00:00

    @TRAN HOANG LONG did u got answer this question

    0 comments No comments