RichEditControl.HoverMenuShowing Event

Fires before the hover menu of the control is displayed.

Namespace: DevExpress.Xpf.RichEdit

Assembly: DevExpress.Xpf.RichEdit.v20.1.dll

Declaration

public event HoverMenuShowingEventHandler HoverMenuShowing
Public Event HoverMenuShowing As HoverMenuShowingEventHandler

Event Data

The HoverMenuShowing event's data class is HoverMenuShowingEventArgs. The following properties provide information specific to this event:

Property Description
Menu Gets or sets the hover menu displayed in the RichEditControl.

Remarks

Handle the HoverMenuShowing event to modify the default hover menu of the RichEditControl.

NOTE

The Hover menu is available only when the RichEditControl provides a Bar or Ribbon UI. Otherwise, the HoverMenuShowing event does not occur. To learn how to implement a Bar/Ribbon interface, refer to the Lesson 1 - Create a Simple Rich Text Editor and Lesson 2 - Create Separate Command UI for a Rich Text Editor documents.

hovermenu

This code snippet demonstrates how to handle the RichEditControl.HoverMenuShowing event to add and remove menu items. Menu buttons representing the IncrementIndentCommand and the DecrementIndentCommand commands are removed. A new custom command MySmileyCommand, which implements the ICommand interface, is added to the menu.

Imports System.Windows
Imports DevExpress.Xpf.Bars
Imports DevExpress.Xpf.RichEdit
Imports DevExpress.XtraRichEdit
Imports DevExpress.XtraRichEdit.Commands
Imports DevExpress.XtraRichEdit.Menu
Imports DevExpress.Xpf.RichEdit.Menu
        Private Sub richEditControl1_HoverMenuShowing(ByVal sender As Object, ByVal e As HoverMenuShowingEventArgs)
            ' Remove DecreaseIndent and IncreaseIndent command menu items.
            For i As Integer = 0 To e.Menu.ItemsCount - 1
                Dim bLink As BarItemLink = CType(e.Menu.ItemLinks(i), BarItemLink)
                Dim cmd As RichEditUICommand = CType(bLink.Item.Command, RichEditUICommand)
                If cmd.CommandId = RichEditCommandId.DecreaseIndent OrElse cmd.CommandId = RichEditCommandId.IncreaseIndent Then
                    e.Menu.ItemLinks.Remove(bLink)
                End If
            Next i
            ' Add a separator.
            Dim itemSep As New BarItemLinkSeparator()
            e.Menu.ItemLinks.Add(itemSep)
            ' Create a new menu item and add it to the hover menu.
            Dim item1 As New RichEditMenuItem()
            item1.Content = "Replace Emoticon with Smiley"
            Dim cmd_toAdd As New MySmileyCommand(richEditControl1)
            item1.Command = cmd_toAdd
            item1.Glyph = cmd_toAdd.Glyph
            e.Menu.ItemLinks.Add(item1)
        End Sub
See Also