xamarin / XamarinCommunityToolkit

The Xamarin Community Toolkit is a collection of Animations, Behaviors, Converters, and Effects for mobile development with Xamarin.Forms. It simplifies and demonstrates common developer tasks building iOS, Android, and UWP apps with Xamarin.Forms.
MIT License
1.59k stars 474 forks source link

TabIndicator not showing when landing on page - iOS Only #1012

Open LeoJHarris opened 3 years ago

LeoJHarris commented 3 years ago

Appears like a bug that when landing on a page with the TabView that the TabIndicatorColor is not showing initially, when I select another tab then the color changes. The color of the TabIndicatorColor is referenced as a DynamicResource in XAML.

Expected Behavior

Color of the TabIndicatorColor should show when page appeared

Actual Behavior

The TabIndicatorColor does not show when page appear and only shows when selecting a new tab then the TabIndicatorColor indicated the correct color for the selected tab

Basic Information

Workaround

NONE

Reproduction imagery

When page is first appeared the TabIndicatorColor is not shown:

Capture

When selecting the next tab it then shows:

Capture1

Reproduction Link

Kapusch commented 3 years ago

I also have noticed this bug many times, but I cannot say why...

Actually, anytime I sign out / sign in again to my app, then I'm able to the the TabIndicatorColor once landing on page !

I guess it could be something related to events ordering, BindingContext initializations... I'll comment more in case I get it.

Kapusch commented 3 years ago

Hi @LeoJHarris ,

Did you try just setting "SelectedIndex" property with a default value ? SelectedIndex="0"

LeoJHarris commented 3 years ago

@Kapusch yes same issue occurs

LeoJHarris commented 3 years ago

@Kapusch If this is only occurring on iOS and not on android then how could events ordering, BindingContext initializations be factors are these handled differently on iOS?

Mirksar commented 3 years ago

I am also having this issue on my app.

I have noticed that this this bug is only happening when the TabView page is opened using Application.Current.MainPage.Navigation.PushAsync

When setting the page directly as Application.Current.MainPage the TabIndicatorColor is showing correctly.

Kapusch commented 2 years ago

Hi @LeoJHarris , I'm facing this issue once again, and I may have found a workaround. Could you try to set the SelectedIndex in the view "OnAppearing" event ? (not working if set in the view constructor)

Of course, this supposes to work on ContentPage views, I'm still trying to find a way to make it work for my ContentView views.

LeoJHarris commented 2 years ago

@Kapusch there is a better work around to set the TabIndicatorView yourself in XAML as shown below.

<xct:TabView>
        <xct:TabView.TabIndicatorView>
            <BoxView
                WidthRequest="{Binding Source={x:Reference tabItemBase}, Path=Width}" />
        </xct:TabView.TabIndicatorView>

        <xct:TabViewItem
            x:Name="tabItemBase"