I have a treeView in a userControl:
<TreeView x:Name="treeData"
Background="#282828" BorderThickness="0" Padding="0,5,0,0"
SelectedValuePath="Uid">
<TreeViewItem Header="Data1" x:Name="tData1" Uid="tabData1">
<TreeViewItem Header="Data1-1" x:Name="tP1" Uid="Data1"/>
<TreeViewItem Header="Data1-2" x:Name="tP2" Uid="Data1"/>
</TreeViewItem>
<TreeViewItem Header="Data2" x:Name="tData2" Uid="tabData2"/>
<TreeViewItem Header="Data3" x:Name="tData3" Uid="tabData3"/>
<TreeViewItem Header="Data4" x:Name="tData4" Uid="tabData4"/>
<TreeViewItem Header="Data5" x:Name="tData5" Uid="tabData5"/>
<TreeViewItem Header="Data6" x:Name="tData6" Uid="tabData6"/>
<TreeViewItem Header="Data7" x:Name="tData7" Uid="tabData7"/>
</TreeView>
and a TabControl in the MainWindow:
<TabControl Grid.Column="1">
<TabItem Header="tabPs"
</TabItem>
<TabItem Header="tabPln"
</TabItem>
<TabItem Header="tabLn"
</TabItem>
<TabItem Header="tabAx"
</TabItem>
<TabItem Header="tabSp"
</TabItem>
<TabItem Header="tabPL">
</TabItem>
<TabItem Header="tabPk">
</TabItem>
<TabItem Header="tabAP"/>
</TabItem>
</TabControl>
I need to be able to have the correct tabItem selected when the user clicks on an Item in the UserControl TreeView Item. Is there a way to bind the selection of the treeView within the UserControl to select a tab on the MainWindow?
I'd previously asked a similar question here:
WPF C# Bind multiple treeViewItems isSelected to tabItem isSelected
but it is aimed at a userControl that has the tabControl as opposed to the TreeView and I'm struggling to see how to bind it when the TreeView is in the UserControl and the tabControl is in the MainWindow
The user control is within the MainWindow within a grid:
<views:TreeViewCntrl Grid.Column="1" x:Name="treeViewGeo">
</views:TreeViewCntrl>