Skip to main content

RichEditControl.HoverMenuShowing Event

Fires before the hover menu of the control is displayed.

Namespace: DevExpress.Xpf.RichEdit

Assembly: DevExpress.Xpf.RichEdit.v23.2.dll

NuGet Package: DevExpress.Wpf.RichEdit

Declaration

public event HoverMenuShowingEventHandler HoverMenuShowing

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 Create a Simple Rich Text Editor and 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.

using System.Windows;
using DevExpress.Xpf.Bars;
using DevExpress.Xpf.RichEdit;
using DevExpress.XtraRichEdit;
using DevExpress.XtraRichEdit.Commands;
using DevExpress.XtraRichEdit.Menu;
using DevExpress.Xpf.RichEdit.Menu;
        void richEditControl1_HoverMenuShowing(object sender, HoverMenuShowingEventArgs e)
        {
            // Remove DecreaseIndent and IncreaseIndent command menu items.
            for (int i = 0; i < e.Menu.ItemsCount; i++) {
                BarItemLink bLink = (BarItemLink)e.Menu.ItemLinks[i];
                RichEditUICommand cmd = (RichEditUICommand)bLink.Item.Command;
                if (cmd.CommandId == RichEditCommandId.DecreaseIndent 
|| cmd.CommandId == RichEditCommandId.IncreaseIndent)
                    e.Menu.ItemLinks.Remove(bLink); 
            }
            // Add a separator.
            BarItemLinkSeparator itemSep = new BarItemLinkSeparator();
            e.Menu.ItemLinks.Add(itemSep);
            // Create a new menu item and add it to the hover menu.
            RichEditMenuItem item1 = new RichEditMenuItem();
            item1.Content = "Replace Emoticon with Smiley";
            MySmileyCommand cmd_toAdd = new MySmileyCommand(richEditControl1);
            item1.Command = cmd_toAdd;
            item1.Glyph = cmd_toAdd.Glyph;
            e.Menu.ItemLinks.Add(item1);
        }
See Also