Key Properties
This topic will go through the key properties of RadContextMenu as follows
- IconColumnWidth
- StaysOpen
- HorizontalOffset
- EventName
- ModifierKey
- MousePosition
- UIElement
- VerticalOffset
- InheritDataContext
IconColumnWidth
By default RadContextMenu displays a column used for visualizing the icons of the menu items.
Its width can be controlled through the IconColumnWidth property. For example, it can be entirely hidden by setting the property value to 0.
Example 1: Setting the IconColumnWidth property
<telerik:RadContextMenu IconColumnWidth="0"/>
Figure 1: RadContextMenu with hidden icon column
StaysOpen
Setting this property manipulates whether RadContextMenu will close automatically or not. Its default value is False. By setting it to True RadContextMenu will stay open when the user clicks the menu items.
HorizontalOffset
RadContextMenu provides a mechanism for controlling the horizontal distance between the target origin and the popup alignment point through the HorizontalOffset property.
Example 2: Setting the HorizontalOffset property
<telerik:RadContextMenu HorizontalOffset="150"/>
Figure 2: RadContextMenu with its HorizontalOffset property set
EventName
RadContextMenu can be opened only when a specific event is raised. EventName is the property through which the given event can be pointed to.
ModifierKey
The ModifierKey property is used in conjunction with the EventName one. It is used when opening RadContextMenu only for a specific event is needed, but with a specified modifier key pressed as well. It is an enumeration type and has the following values.
MousePosition
The MousePosition property provides information regarding the position of the mouse at the moment when the menu was opened relative to the element that caused its opening. It returns a Point value.
UIElement
Returns the instance of the element to which RadContextMenu is attached.
VerticalOffset
Similarly to the HorizontalOffset property, the VerticalOffset one provides a mechanism for setting the vertical distance between the target origin and the popup alignment point.
InheritDataContext
By default, the RadContextMenu inherits the DataContext of its parent element. If you want to avoid that, you can set the InheritDataContext property to False.