I am creating TabbedPage navigation in my project and I have button in page 1, when you click the button it must be go to page 2. It will slide on page 2 of the tabbedpage.
This is how i design my TabbedPage XAML
<TabbedPage
android:TabbedPage.IsSmoothScrollEnabled="True" >
<local:Home Title="Home"/>
<local:MapsLocation Title="Map"/>
<local:FeedbackPage Title="Feedback"/>
<local:Profile Title="Profile"/>
</TabbedPage>
This is my code in my code in button command
public ICommand GotoCommand { get; }
private async void GotoExecute(object sender)
{
var MyObject = (Shop)sender;
await Navigation.PushAsync(new MapsLocation(MyObject.Address));
}
Page 1 when you click the button, It should be slide into the Page 2
Page 2, it should go here when you click the button in the page 1
It should be sliding into child 2 of TabbedPage
How do i achieve this?
CodePudding user response:
If you want to slide to other Tabbedpage
, you can use the code below to achieve it. Note that the index of the tab.Children[index] starts from 0
and it should <
the count of child tabbedpage or it'll throw the error Index was out of range
.
private void Button_Clicked(object sender, EventArgs e)
{
var tab = this.Parent as TabbedPage;
tab.CurrentPage = tab.Children[1];
}