I have a TabControl with a ContentTemplate defining a CheckBox. Outside the TabControl I want to bind to the CheckBox in the currently selected TabItem. How can I do that?
In the code below the CheckBox "Mirror" is bound to a CheckBox on the same level, which works. How can I make the Mirror-CheckBox to mirror tabCheckbox?
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<TabControl Grid.Row="0">
<TabControl.ContentTemplate>
<DataTemplate>
<CheckBox
Name="tabCheckbox"
Content="Check me"
/>
</DataTemplate>
</TabControl.ContentTemplate>
<TabItem Header="Tab 1">
</TabItem>
</TabControl>
<CheckBox
x:Name="checkbox"
Grid.Row="1"
Content="Some CheckBox"
/>
<CheckBox
Grid.Row="2"
Content="Mirror"
IsChecked="{Binding ElementName=checkbox, Path=IsChecked}"
/>
</Grid>