See this question on how to do this programmatically. The trick is to install ContextMenu on any control that you set as the contents of the header. If you just use the header to set a simple string value, this will not work. At a minimum, you need to create a TextBlock or ContentControl or something like that.
For those who are interested in how to do this using XAML (especially when using the MVVM template):
Set ContextMenu in the ItemContainerStyle TabControl. It will only apply to the actual tab (title), and not to the contents of the tab. You can use bindings, etc. In MenuItems to get a variety of tab-based behaviors if your tab uses ViewModel ..
<TabControl> <TabControl.ItemContainerStyle> <Style TargetType="{x:Type TabItem}"> <Setter Property="ContextMenu"> <Setter.Value> <ContextMenu/> </Setter.Value> </Setter> </Style> </TabControl.ItemContainerStyle> </TabControl>
source share