This project is read-only.

DocumentTabItemStyle StackPanel

Sep 14, 2009 at 2: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" 
            Margin="5,0,4,0">
	<TextBlock 
            x:Name="tabItemTitle" 
            TextTrimming="CharacterEllipsis" 
            TextWrapping="NoWrap"
            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"/>
	</ad:AlignedImage>
</StackPanel>

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);
    }
}

Juergen

Sep 14, 2009 at 3: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.

Ado

Sep 14, 2009 at 3:18 PM

I think, you are right.

I'll give it a try.

Juergen

Sep 16, 2009 at 2:15 PM

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

You can find it here:

http://avalondock.codeplex.com/Wiki/View.aspx?title=Document%20tab%20restyling

Ado

 

Sep 17, 2009 at 5:50 PM

Ado,

That's really cool - and so simple.

Thanks a lot.

Juergen