Although I did not find a direct way to prevent docking, I managed to fix the main problem, namely, to configure various tab headers for tool windows and document windows. My document windows show an asterisk (*) in the tab title to indicate changes (like VS), while tool windows should not.
The solution was to use the DocumentHeaderTemplateSelector and provide it with two different templates: one for documents and tool windows. Here's the XAML:
<xcad:DockingManager.DocumentHeaderTemplateSelector> <bd:DocumentHeaderTemplateSelector> <bd:DocumentHeaderTemplateSelector.DocumentTemplate> <DataTemplate> <StackPanel Orientation="Horizontal"> <Image Source="Resources\AppIcon.ico" Margin="0,0,4,0" Width="16" /> <TextBlock Text="{Binding Title}" /> <TextBlock Text=" *" Visibility="{Binding Content.IsDirty, Converter={StaticResource BoolToVisibilityConverter}}" /> </StackPanel> </DataTemplate> </bd:DocumentHeaderTemplateSelector.DocumentTemplate> <bd:DocumentHeaderTemplateSelector.ToolWindowTemplate> <DataTemplate> <StackPanel Orientation="Horizontal"> <TextBlock Text="{Binding Title}" /> </StackPanel> </DataTemplate> </bd:DocumentHeaderTemplateSelector.ToolWindowTemplate> </bd:DocumentHeaderTemplateSelector> </xcad:DockingManager.DocumentHeaderTemplateSelector>
The selector class is simple:
Public Class DocumentHeaderTemplateSelector Inherits DataTemplateSelector Public Property DocumentTemplate As DataTemplate Public Property ToolWindowTemplate As DataTemplate Public Overrides Function SelectTemplate(item As Object, container As System.Windows.DependencyObject) As System.Windows.DataTemplate Dim itemAsLayoutContent = TryCast(item, Xceed.Wpf.AvalonDock.Layout.LayoutContent) If TypeOf item Is Xceed.Wpf.AvalonDock.Layout.LayoutDocument AndAlso TypeOf DirectCast(item, Xceed.Wpf.AvalonDock.Layout.LayoutDocument).Content Is DocumentVM Then Return DocumentTemplate Else Return ToolWindowTemplate End If End Function End Class
Now my tool windows do not show an asterisk (*) and icon, even if they are moved to the document panel.
Hope this helps someone along the way.
dotNET
source share