Selector.SelectionChanged Event occurs when the selection of a Selector changes. The ChildTab
is included in ParentTab Selector
, ChildTab selectionChanged causes ParentTab to has a selectionChanged.
I make some update to your code and use MouseLeftButtonDown to replace selectionChanged. Below is my code for you:
XAML code:
<TabControl>
<TabControl.ItemContainerStyle>
<Style TargetType="TabItem" BasedOn="{StaticResource {x:Type TabItem}}">
<Setter Property="HeaderTemplate">
<Setter.Value>
<DataTemplate>
<Label Content="{Binding}" Name="ParentTab">
<Label.Style>
<Style TargetType="Label">
<EventSetter Event="MouseLeftButtonDown" Handler="Label_MouseLeftButtonDown"/>
</Style>
</Label.Style>
</Label>
</DataTemplate>
</Setter.Value>
</Setter>
</Style>
</TabControl.ItemContainerStyle>
<TabItem Header="TabItem1" />
<TabItem Header="TabItem2">
<TabControl Name="ChildTab" TabStripPlacement="Left">
<TabItem Header="TabItem3" />
<TabItem Header="TabItem4" />
</TabControl>
</TabItem>
</TabControl>
C# code is:
private void Label_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
Debug.Print("\n ************ Sent from " + (sender as Label).Name);
}
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.