Open SeRgI1982 opened 3 years ago
Unfortunately, it looks like every time the binding context of the TabView changes, it sets each of the TabViewItems to the same BindingContext as the TabView.
I also have this requirement, and I have been able to find a workaround.
Initially, I was assigning BindingContext property directly in my MainView XAML file, for each TabViewItem component:
<xct:TabView>
<xct:TabViewItem>
<view:TabView1 x:Name="TabView1" BindingContext = "{Binding TabView1ViewModel}"/>
</xct:TabViewItem>
<xct:TabViewItem>
<view:TabView2 x:Name="TabView2" BindingContext = "{Binding TabView2ViewModel}"/>
</xct:TabViewItem>
<xct:TabViewItem>
<view:TabView3 x:Name="TabView3" BindingContext = "{Binding TabView3ViewModel}"/>
</xct:TabViewItem>
</xct:TabView>
But instead, I assign BindingContext property for each in "OnAppearing" method of my MainView:
protected override void OnAppearing()
{
TabView1.BindingContext = (this.BindingContext as MainViewModel).TabView1ViewModel;
TabView2.BindingContext = (this.BindingContext as MainViewModel).TabView2ViewModel;
TabView3.BindingContext = (this.BindingContext as MainViewModel).TabView3ViewModel;
}
I am experiencing the same issue.
Description
Because TabViewItem content can be heavy and it can be related with very thick ViewModel, I would like to delegate (separate) this data management to another ViewModel's which are injected into my MainPageViewModel.
Steps to Reproduce
Expected Behavior
TabViewItem.Content.BindingContext points to property in visible in XAML
Actual Behavior
TabViewItem.Content.BindingContext automatically switch to main Page ViewModel
Basic Information
Version with issue: 1.0.3 like also 1.1.0-pre1
IDE: VS for Mac
Platform Target Frameworks:
Sample app below:
Steps:
TabViewTest.zip