|
Yes my assumption was correct and I fixed it too but I was confused, I'll tell you why:
In generic.xaml it is assigning an icon and a header template:
<avalonDockControls:ContextMenuEx.ItemContainerStyle>
<Style TargetType="{x:Type avalonDockControls:MenuItemEx}">
<Setter Property="HeaderTemplate" Value="{Binding Path=Root.Manager.DocumentPaneMenuItemHeaderTemplate}"/>
<Setter Property="HeaderTemplateSelector" Value="{Binding Path=Root.Manager.DocumentPaneMenuItemHeaderTemplateSelector}"/>
<Setter Property="IconTemplate" Value="{Binding Path=Root.Manager.IconContentTemplate}"/>
<Setter Property="IconTemplateSelector" Value="{Binding Path=Root.Manager.IconContentTemplateSelector}"/>
<Setter Property="Command" Value="{Binding Path=., Converter={StaticResource ActivateCommandLayoutItemFromLayoutModelConverter}}"/>
</Style>
</avalonDockControls:ContextMenuEx.ItemContainerStyle>
It was using the same template so I created a new separate template for menu items:
<!-- AJC 13/9/12 Use new menu header template to stop doubling up of icons because the menu already has an icon -->
<!--<Setter Property="DocumentPaneMenuItemHeaderTemplate" Value="{StaticResource DocumentHeaderTemplate}"/>-->
<Setter Property="DocumentPaneMenuItemHeaderTemplate" Value="{StaticResource DocumentMenuHeaderTemplate}" />
Defined here:
<!-- AJC 13/9/12: new document menu header template -->
<DataTemplate
x:Key="DocumentMenuHeaderTemplate">
<TextBlock Text="{Binding Title}" TextTrimming="CharacterEllipsis"/>
</DataTemplate>
But then it still did not work and I could not understand why - it was still using the DocumentHeaderTemplate for menu items.
Then I found the problem in DockingManager.cs:
protected virtual void OnDocumentHeaderTemplateChanged(DependencyPropertyChangedEventArgs e)
{
// AJC 13/9/12: Don't do this because it seems to be stopping DocumentPaneMenuItemHeaderTemplate from being set
//if (DocumentPaneMenuItemHeaderTemplate == null)
// DocumentPaneMenuItemHeaderTemplate = DocumentHeaderTemplate;
}
The document header template is set first and so it was setting the menu template to a copy of the document header template. I don't understand why it didn't then go and set the menu item template but the above code stops it for some reason. Commenting
it out fixes the problem and the menu item header template gets set.
|