Skip to main content
A newer version of this page is available. .
Bar

RadialContextMenu Class

The menu where items are arranged in a circle.

Namespace: DevExpress.Xpf.Bars

Assembly: DevExpress.Xpf.Core.v18.2.dll

Declaration

public class RadialContextMenu :
    PopupMenu

Remarks

A Radial Menu is a Microsoft Note 2013 inspired pop-up menu, in which items are arranged in a circle.

DX-RadialContextMenu.png

In XAML, radial menu items (BarItem and BarItemLink descendants) can be created by defining them between the RadialContextMenu start and end tags. To define a sub-menu item (a menu whose items are displayed at a nested level), use the BarSplitButtonItem object.

You can assign a Radial Menu to a control using the BarManager.DXContextMenu attached property.

Example

This example shows how to assign a RadialContextMenu to a text box and initialize the menu with items.

To assign the RadialContextMenu to the text box, the BarManager.DXContextMenu attached property is used.

The radial menu displays three regular buttons (Copy, Cut and Paste) and one sub-menu (Select All) that provides access to two additional items (Clear and Select All). Commands are assigned to the buttons with the Command properties.

DX-RadialContextMenu-example

The radial menu’s DataContext is bound to the window’s DataContext. This DataContext is set to a RadialContextMenuViewModel class descendant, which is automatically generated by the DevExpress.Mvvm.POCO.ViewModelSource object. This descendant automatically generates commands for all public methods in the RadialContextMenuViewModel class (the ClearSelectionCommand is generated for the ClearSelection method).

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using DevExpress.Mvvm;
using DevExpress.Mvvm.UI;


namespace WpfApplication5 {
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window {
        public MainWindow() {
            InitializeComponent();
        }
    }

    public interface ITextBoxService {
        void ClearSelection();
        bool CanClearSelection();
    }

    public class TextBoxService : ServiceBase, ITextBoxService {
        TextBox MyTextBox { get { return AssociatedObject as TextBox; } }
        public void ClearSelection() {
            MyTextBox.SelectionLength = 0;
        }
        public bool CanClearSelection() {
            return MyTextBox.SelectionLength > 0;
        }
    }


    public class RadialContextMenuViewModel {

        public virtual ITextBoxService TextBoxService { get { return null; } }

        public ICommand CopyCommand { get; set; }
        public ICommand PasteCommand { get; set; }
        public ICommand CutCommand { get; set; }
        public ICommand SelectAllCommand { get; set; }

        public RadialContextMenuViewModel() {
            CopyCommand = ApplicationCommands.Copy;
            PasteCommand = ApplicationCommands.Paste;
            CutCommand = ApplicationCommands.Cut;
            SelectAllCommand = ApplicationCommands.SelectAll;
        }

        // A ClearSelectionCommand is automatically created from the following methods by POCO:
        public bool CanClearSelection() { 
            return TextBoxService.CanClearSelection(); 
        }

        public void ClearSelection() {
            TextBoxService.ClearSelection();            
        }

    }
}

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the RadialContextMenu class.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

Implements

Inheritance

Show 13 items
Object
DispatcherObject
DependencyObject
Visual
UIElement
FrameworkElement
Popup
DevExpress.Xpf.Core.PopupBase
BarPopupBase
DevExpress.Xpf.Bars.BarPopupExpandable
PopupMenuBase
PopupMenu
RadialContextMenu
See Also