C# TabControl.SelectedItem不是TabItem吗?相对资源绑定失败

C# TabControl.SelectedItem不是TabItem吗?相对资源绑定失败,c#,wpf,binding,tabcontrol,relativesource,C#,Wpf,Binding,Tabcontrol,Relativesource,我正在用TabControl做一些尝试,我被这个弄糊涂了 <TabControl Name="MainControl"> <TabItem Header="MyTab1"> <TextBlock Text="{Binding Path=SelectedItem.Header, RelativeSource={RelativeSource FindAncestor, AncestorType=TabControl}}"/> </T

我正在用TabControl做一些尝试,我被这个弄糊涂了

<TabControl Name="MainControl">
    <TabItem Header="MyTab1">
    <TextBlock Text="{Binding  Path=SelectedItem.Header, RelativeSource={RelativeSource FindAncestor, AncestorType=TabControl}}"/>
    </TabItem>
    <TabItem Header="Modules" ContentTemplate="{StaticResource tabItemControl}"/>
</TabControl>

这正如预期的那样有效

然而,这:

<TabControl Name="MainControl">
    <TabItem Header="MyTab1">
    <TextBlock Text="{Binding  Path=Header, RelativeSource={RelativeSource FindAncestor, AncestorType=TabItem}}"/>
    </TabItem>
    <TabItem Header="Modules" ContentTemplate="{StaticResource tabItemControl}"/>
</TabControl>

没有

知道为什么吗

selectedItem不是选项卡项吗?层次结构中有什么不同吗?

如文章所示,TabItem和SelectedContent位于不同的面板中,因此SelectedItem。Header不起作用,因为它实际上不是TabItem

从下面较早的帖子发布snoop图像

我想这就是你要找的