WPF获取button的上级路由控件,求解
我的tabItem里面有button,我现在点击这个button触发事件,我需要获取到这个button是第几个tab item里面。
<Style TargetType="{x:Type TabItem}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type TabItem}">
<Button x:Name="cmdTabItemCloseButton"
Style="{StaticResource TabItemCloseButtonStyle}"
Click="TabItemClose_Click"
Grid.Column="1"
Margin="-7,5,7,5"/>
.....
private void TabItemClose_Click(object sender, RoutedEventArgs e)
{
//需要在这里获取我点击的是第几个tab item
}
求助,谢谢