DocumentTabItemStyle StackPanel

Sep 14, 2009 at 1:18 PM

Hi Ado,
is it possible to add a name to the StackPanel with the Textblock and the LockedIcon inside the themes xaml files?
Sometimes I want to add additional information in the title bar of a DocumentContent.

<StackPanel x:Name="tabItemTitlePanel"  Orientation="Horizontal" 
            Text="{TemplateBinding Title}" 
            Foreground="{DynamicResource {ComponentResourceKey {x:Type ad:DockingManager}, {x:Static ad:AvalonDockBrushes.DocumentHeaderForeground}}}"/>
	<ad:AlignedImage x:Name="PART_LockedIcon" Margin="2,0,0,0" Visibility="Collapsed" VerticalAlignment="Center" HorizontalAlignment="Center">
		<Image Source="/AvalonDock;component/resources/Images/Locked.png" Width="6" Height="8" Stretch="Uniform"/>

The easiest way without changing AvalonDock every time is to get the StackPanel object.
Then I can add or remove items by code like:

void docWindow_Loaded(object sender, RoutedEventArgs e)
    DocumentContent content = (DocumentContent)sender;
    if (content.Template == null) return;
    StackPanel o = content.Template.FindName("tabItemTitlePanel", content) as StackPanel;
    if (o != null)
        Button btn = new Button();
        btn.Content = "Test";
        o.Children.Insert(0, btn);


Sep 14, 2009 at 2:06 PM

Why don't you simply restyle the documentpane?

Adding controls at runtime based on internal names are not safe, I mean, doing so you're linking your client code to a specific theme.


Sep 14, 2009 at 2:18 PM

I think, you are right.

I'll give it a try.


Sep 16, 2009 at 1:15 PM

Jurgen, I've created a tutorial on how to customize a document pane /document tab item.

You can find it here:



Sep 17, 2009 at 4:50 PM


That's really cool - and so simple.

Thanks a lot.