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!
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}"/>
<Label Content="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type TabItem}}, Path=Header}"/>
Thanks to arx for the right direction ;) EDIT: And also thanks to John
<Label Content="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=SelectedItem.Header}" />
精彩评论