How can I add custom context menu to header of ManagedContent?

Mar 1, 2010 at 9:52 AM
Edited Mar 1, 2010 at 12:32 PM

Default content menu for ManagedContent is perfectly good but I want to replace it (or add into it) by some custom context menu that depends of tab content. For example, we have two views - UserControl or Window inheritors - each of them have own context menu:

 

<Window x:Class="View1"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      ...>
      <Window.ContextMenu>
            <ContextMenu>
                  <MenuItem Header="Do action A" Command="{Binding DoActionACommand}"/>
            </ContextMenu>
      </Window.ContextMenu>
</Window>
                
<Window x:Class="View2"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      ...>
      <Window.ContextMenu>
          <ContextMenu>
              <MenuItem Header="Do action B" Command="{Binding DoActionBCommand}"/>
          </ContextMenu>
      </Window.ContextMenu>
</Window>

 

This views are added into DocumentPane:

 

_documents.Items.Add(view1);
_documents.Items.Add(view2);

Is there any build-in posibility to replace (or merge) standart ManagedContent header context menu by this views context menues?

P.S. Yes, we can do something like this:

 
<Style x:Key="DocumentTabItemStyle" TargetType="{x:Type ad:ManagedContent}">
    <Setter Property="Background" Value="Transparent"/>
        <Setter Property="Template">
	    <Setter.Value>
	        <ControlTemplate TargetType="{x:Type ad:ManagedContent}">
		    <Border x:Name="PART_DragArea" 
		        BorderBrush="{StaticResource ManagedContentTabControlNormalBorderBrush}"
                        Margin="-10,0,0,0" SnapsToDevicePixels="True"
                        ContextMenu="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Content.ContextMenu}"
                        >