I'm binding an ObservableCollection to AvalonDock 2.0, where every item in the collection is an AvalonDock Document. This is how I do the binding:
<ad:DockingManager DocumentsSource="{Binding Path=OpenProjects, Mode=TwoWay}" ActiveContent="{Binding Path=CurrentProject, Mode=TwoWay}" LayoutItemTemplateSelector="{StaticResource ProjectTemplateSelector}">
...
</ad:DockingManager>
The problem is I want to show the Name of each item (which is specified in the property Name
in CurrentProject
) as the Document title. This is what I've tried:
<ad:DockingManager.DocumentHeaderTemplate>
<DataTemplate>
<TextBlock DataContext="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=ad:DockingManager}, Path=ActiveContent, Mode=OneWay}" Text="{Binding Path=Name}" />
</DataTemplate>
</ad:DockingManager.DocumentHeaderTemplate>
This works fine if I only have one document open, but when I have several, they all show the Name
of the current project. For example, if I have four open projects, with the names "A", "B", "C" and "D", if I'm currently viewing the document "C", all four tabs will show the title "C", and when I change to document "B", they will all change its names to "B".
Is there any way to prevent this changes? I've tried setting the binding mode to OneTime
, but it doesn't seem to work.