I found the easy way to get the ContextMenu template in Blend:
- I added a ContextMenu to a button with some menuitems.
- Under "miscellaneous" in the properties pane, there's a grouped item for ContextMenu.
- Open this. You'll find the usual Style and Template properties.
- Click the square for the popup menu, and select Convert to New Resource...
That's it. Pick where you want the template/style to be put, and you're done.
Here's the markup I had:
<StackPanel x:Name="LayoutRoot">
<Button Content="Click for ContextMenu" Width="30" HorizontalAlignment="Center" VerticalAlignment="Center">
<Button.ContextMenu>
<ContextMenu Template="{DynamicResource ContextMenuControlTemplate1}" Style="{DynamicResource ContextMenuStyle1}">
<MenuItem Header="File"/>
<MenuItem Header="Edit"/>
<MenuItem Header="View"/>
<MenuItem Header="Recent Files"/>
<MenuItem Header="file1.txt"/>
<MenuItem Header="file2.txt"/>
</ContextMenu>
</Button.ContextMenu>
</Button>
</StackPanel>
And the style/template I got:
<Style x:Key="ContextMenuStyle1" TargetType="{x:Type ContextMenu}">
<Setter Property="Background" Value="{DynamicResource MenuBackgroundBrush}"/>
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="BorderBrush" Value="{DynamicResource WindowBorderBrush}"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ContextMenu}">
<Border Uid="Border_93">
<Border.Style>
<Style TargetType="{x:Type Border}">
<Setter Property="Tag" Value="{DynamicResource {x:Static SystemParameters.DropShadowKey}}"/>
<Style.Triggers>
<DataTrigger Binding="{Binding Tag, RelativeSource={RelativeSource Self}}" Value="True">
<Setter Property="Background" Value="Transparent"/>
<Setter Property="Padding" Value="0,0,5,5"/>
<Setter Property="Effect">
<Setter.Value>
<DropShadowEffect BlurRadius="4" Opacity="0.8" ShadowDepth="1"/>
</Setter.Value>
</Setter>
</DataTrigger>
</Style.Triggers>
</Style>
</Border.Style>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
Hope this helps. In usual MS thoroughness, the brushes in the default style aren't found. :)