ContextMenuItem ClassDW.WPFToolkit Documentation
Brings an easy to use MenuItem to be used in the ContextMenu no matter if its in an own VisualTree or not.
Inheritance Hierarchy

SystemObject
  System.Windows.ThreadingDispatcherObject
    System.WindowsDependencyObject
      System.Windows.MediaVisual
        System.WindowsUIElement
          System.WindowsFrameworkElement
            System.Windows.ControlsControl
              System.Windows.ControlsItemsControl
                System.Windows.ControlsHeaderedItemsControl
                  System.Windows.ControlsMenuItem
                    DW.WPFToolkit.ControlsContextMenuItem

Namespace: DW.WPFToolkit.Controls
Assembly: DW.WPFToolkit (in DW.WPFToolkit.dll) Version: 5.6.0.0
Syntax

C#
public class ContextMenuItem : MenuItem

The ContextMenuItem type exposes the following members.

Constructors

  NameDescription
Public methodContextMenuItem
Initializes a new instance of the ContextMenuItem class
Top
Methods

  NameDescription
Protected methodOnInitialized
Called when the IsInitialized property is set to true.
(Overrides MenuItemOnInitialized(EventArgs).)
Top
Fields

  NameDescription
Public fieldStatic memberElementHolderProperty
Identifies the ElementHolder dependency property.
Public fieldStatic memberIsBindToSelfProperty
Identifies the IsBindToSelf dependency property.
Public fieldStatic memberItemDataContextProperty
Identifies the ItemDataContext dependency property.
Top
Properties

  NameDescription
Public propertyElementHolder
Gets or sets a placeholder for the current item parent from the other visual tree. This is used internally, please do not set it to another value otherwise the ContextMenuItem will not work properly.
Public propertyIsBindToSelf
The DataContext will be the element like original.
Public propertyItemDataContext
Gets or sets the data as original DataContext for the case the DataContext get changed to the parent object.
Top
Examples

XAML
<TextBlock Text="{Binding Name}">
    <TextBlock.ContextMenu>
        <ContextMenu>
            <Toolkit:ContextMenuItem Header="Edit Global"
                                     Command="{Binding EditCommand}"
                                     CommandParameter="{Binding ItemDataContext, RelativeSource={RelativeSource Self}}" />
            <Toolkit:ContextMenuItem Header="Edit Directly"
                                     IsBindToSelf="True"
                                     Command="{Binding EditCommand}" />
        </ContextMenu>
    </TextBlock.ContextMenu>
</TextBlock>
See Also

Reference