This repository was archived by the owner on May 1, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 455
This repository was archived by the owner on May 1, 2024. It is now read-only.
[Bug] Setting TabView.SelectedIndex does not "visually" switch tabs #595
Copy link
Copy link
Closed
Labels
a/TabViewbugSomething isn't working. Breaky break.Something isn't working. Breaky break.s/unverifiedThis issue needs verification/reproduction by a team member. PRs cannot be accepted/merged.This issue needs verification/reproduction by a team member. PRs cannot be accepted/merged.
Description
Description
If I programmatically set the SelectedIndex of a TabView to say 1 when it is originally on SelectedIndex of 0, it appears that internally the new Tab is selected but visually the the TabView appears to still be on Tab 0. If you were then to physically tap on Tab 1, nothing would happen since it is internally already on Tab 1. Tapping on Tab 0 and then Tab 1 will finally successfully show Tab 1. See gif below:
Steps to Reproduce
XAML:
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:xct="http://xamarin.com/schemas/2020/toolkit"
x:Class="App4.MainPage">
<StackLayout>
<Button Text="Change Tab"
Clicked="Button_Clicked" />
<xct:TabView x:Name="MyTabView"
TabIndicatorPlacement="Bottom"
TabIndicatorColor="Orange">
<xct:TabViewItem Text="First">
<Label Text="First Tab" />
</xct:TabViewItem>
<xct:TabViewItem Text="Second">
<Label Text="Second Tab" />
</xct:TabViewItem>
</xct:TabView>
</StackLayout>
</ContentPage>Code Behind:
namespace App4
{
public partial class MainPage : ContentPage
{
public MainPage()
{
InitializeComponent();
}
private void Button_Clicked(object sender, EventArgs e)
{
MyTabView.SelectedIndex = 1;
}
}
}Expected Behavior
Upon button click, the TabView should visually navigate to the next Tab on SelectedIndex change.
Actual Behavior
Basic Information
- Version with issue: 1.0.0-pre5
- IDE:
- Platform Target Frameworks:
- iOS: 14.2
- Android: 10.0
Workaround
MethodInfo dynMethod = MyTabView.GetType().GetMethod("UpdateSelectedIndex", BindingFlags.NonPublic | BindingFlags.Instance);
dynMethod?.Invoke(MyTabView, new object[] { 1, false });leo-mck, malikberkane, GiampaoloGabba and bolorundurowb
Metadata
Metadata
Assignees
Labels
a/TabViewbugSomething isn't working. Breaky break.Something isn't working. Breaky break.s/unverifiedThis issue needs verification/reproduction by a team member. PRs cannot be accepted/merged.This issue needs verification/reproduction by a team member. PRs cannot be accepted/merged.
