question

TRANHOANGLONG-3536 avatar image
0 Votes"
TRANHOANGLONG-3536 asked ColeXia-MSFT answered

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

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.


dotnet-xamarin
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

ColeXia-MSFT avatar image
0 Votes"
ColeXia-MSFT answered

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.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.