XamarinCommunityToolkit icon indicating copy to clipboard operation
XamarinCommunityToolkit copied to clipboard

[Bug] TabView does not respect the BindingContext the user manually assigns to TabViewItems

Open mtsrdr opened this issue 5 years ago • 7 comments

Stackoverflow question

Prism View is being assigned parent page ViewModel inside XCT tabview

Description

TabView overwrites the BindingContext value of TabViewItems content views.

https://github.com/xamarin/XamarinCommunityToolkit/blob/3abf5fa7eeaa29e76e9b1bfeb17575b75bccc799/src/CommunityToolkit/Xamarin.CommunityToolkit/Views/TabView/TabView.shared.cs#L430-L439

Steps to Reproduce

  1. Create a new project with TabView and add some TabViewItems
  2. Set a different BindingContext value to TabViewItem's Content views
  3. Run the app and check if BindingContext of TabViewItems is the same the user assigned to them

Expected Behavior

TabView should respect the BindingContext the user assigns to TabViewItems

Actual Behavior

TabView overwrites the BindingContext value of TabViewItems.

Basic Information

  • Version with issue 1.0.3:

Reproduction Link

TabViewIssue1091.zip

Workaround

Wrap the content of the tab in a ContentView:

          <xct:TabViewItem Text="Home">
            <xct:TabViewItem.Content>
                <ContentView>
                    <local:HomeView BindingContext="{Binding HomeViewModel}" />
                </ContentView>
            </xct:TabViewItem.Content>
        </xct:TabViewItem>

mtsrdr avatar Mar 17 '21 03:03 mtsrdr

I just updated the issue to include the reproduction project.

mtsrdr avatar Mar 17 '21 17:03 mtsrdr

Same issue is here for me.

kerberosargos avatar Apr 11 '21 18:04 kerberosargos

The same here. The ContentView workaround is working for now.

l0gaw avatar May 13 '21 11:05 l0gaw

Same issue still persists for me.

The same here. The ContentView workaround is working for now.

Could you please tell me what the ContentView workaround is? Thank you.

danielftz avatar Jul 06 '21 17:07 danielftz

Same issue still persists for me.

The same here. The ContentView workaround is working for now.

Could you please tell me what the ContentView workaround is? Thank you.

Nevermind, recent update has resolved this issue.

danielftz avatar Jul 06 '21 18:07 danielftz

Same issue still persists for me.

The same here. The ContentView workaround is working for now.

Could you please tell me what the ContentView workaround is? Thank you.

Nevermind, recent update has resolved this issue.

Already released? I´m using the last 1.3.0 version and it is still failing, anyway the workaround is working fine.

scastiello avatar Nov 25 '21 10:11 scastiello

still happening on 1.3.2. The workaround seems to fix it.

scotch83 avatar Oct 14 '22 09:10 scotch83