tags:

views:

10

answers:

3

Hi Guys, I'm trying to display the Title of an Tabitem in his contentpresenter. Is there a possibility to get this name?

For example in the Tabcontrol Template something like

<Label>
    <ContentPresenter ContentSource="SelectedContentHeader" Grid.Row="1" />
</Label>

to display the name of the current tab in label.

Thanks in advance!

+1  A: 

I'm not quite sure what you are trying to do, (e.g. is the label part of a control template or separate?), but this displays tabControl1's current TabItem's name in a label:

<Label Content="{Binding ElementName=tabControl1,Path=SelectedItem.Header}"/>
arx
Yes, the label is part of a control template. So I think this won't work. But you helped me to an idea that worked:
Thomas Spranger
A: 

Thanks to arx for the right direction ;) EDIT: And also thanks to John

   <Label Content="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=SelectedItem.Header}" />
Thomas Spranger
A: 
<Label Content="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type TabItem}}, Path=Header}"/>
John Bowen