Infragistics(R) NetAdvantage(R) : WPF 2012.1
Opening and Showing xamContextMenu
E-mail your feedback on this topic.
Shared XAML > Menus > xamContextMenu > Using xamContextMenu > Opening and Showing xamContextMenu

Glossary Item Box

By default, the xamContextMenu™ control will be displayed when your end users release the right-mouse button. The ContextMenuManager object gives you several options to change this default behavior.

The following code gives you an example how you can change the default (right click) opening mode to left mouse click and set the ModifierKeys property to a combination of Control and Shift key.

In XAML:

<TextBox Name="textBox1">
    
    <!--
    Example of using the Infragistics Commanding Framework to open the context menu:
    -->

    <!--
    <igWPF:Commanding.Command>
        <ig:XamContextMenuCommandSource 
            CommandType="Open" 
            EventName="SelectionChanged" 
            TargetName="contextMenu1" />
    </igWPF:Commanding.Command>
    -->
    
    
    <ig:ContextMenuService.Manager>
        <!--If you use the Infragistics Commanding Framework, you should set the OpenMode property to None-->
        <ig:ContextMenuManager ModifierKeys="Control, Shift" OpenMode="LeftClick">
            <ig:ContextMenuManager.ContextMenu>
                <ig:XamContextMenu Name="contextMenu1">
                    <ig:XamMenuItem Header="Font" />
                    <ig:XamMenuItem Header="Formatting" />
                </ig:XamContextMenu>
            </ig:ContextMenuManager.ContextMenu>
        </ig:ContextMenuManager>
    </ig:ContextMenuService.Manager>
</TextBox>

In Visual Basic:

Imports Infragistics.Controls.Menus
Imports Infragistics
...
Dim contextMenuManager1 As New ContextMenuManager()
contextMenuManager1.ModifierKeys = ModifierKeys.Control Or ModifierKeys.Shift
contextMenuManager1.OpenMode = OpenMode.LeftClick

'TODO: Create a xamContextMenu and add XamMenuItem objects to it.
'TODO: Set the ContextMenuManager object's ContextMenu property to the xamContextMenu control.

ContextMenuService.SetManager(textBox1, contextMenuManager1)
...

In C#:

using Infragistics.Controls.Menus;
using Infragistics;
...
ContextMenuManager contextMenuManager1 = new ContextMenuManager
{
    ModifierKeys = ModifierKeys.Control | ModifierKeys.Shift,
    OpenMode = OpenMode.LeftClick
};

//TODO: Create a xamContextMenu and add XamMenuItem objects to it.
//TODO: Set the ContextMenuManager object's ContextMenu property to the xamContextMenu control.

ContextMenuService.SetManager(textBox1, contextMenuManager1);
...
Related Topics

Set xamContextMenu's Location

Binding to Data

Adding and Removing Items

Adding Separators between XamMenuItems

Adding Icons to XamMenuItems

Adding Check Boxes to XamMenuItems