New to Telerik UI for WPFStart a free 30-day trial

How to Add Context Menu to RadGridView FilteringControl

Updated on Sep 15, 2025

Environment

ProductRadGridView for WPF

Description

How to display a context menu for elements inside the FilteringControl of the RadGridView.

Solution

Create a class that inherits from FilteringControl and handle the PreviewMouseRightButtonDown event. Inside the event handler, add the logic for displaying the context menu.

Example 1: Creating a custom FilteringControl

C#

	public class ExtendedFilteringControl : FilteringControl
    {
        public RadContextMenu contextMenu;

        public ExtendedFilteringControl(Telerik.Windows.Controls.GridViewColumn column)
        : base(column)
        {
            DefaultStyleKey = typeof(ExtendedFilteringControl);
            this.Loaded += FilteringControlEx_Loaded;
        }

        private void FilteringControlEx_Loaded(object sender, RoutedEventArgs e)
        {
            contextMenu = new RadContextMenu();
            contextMenu.Items.Add(new RadMenuItem() { Header = "Copy", Command = ApplicationCommands.Copy });
            this.PreviewMouseRightButtonDown += ExtendedFilteringControl_PreviewMouseRightButtonDown;
        }

        private void ExtendedFilteringControl_PreviewMouseRightButtonDown(object sender, MouseButtonEventArgs e)
        {
            var placementTarget = e.OriginalSource as FrameworkElement;

            if (placementTarget.ParentOfType<TextBox>() != null)
            {
                contextMenu.PlacementTarget = placementTarget;
                contextMenu.Placement = System.Windows.Controls.Primitives.PlacementMode.MousePoint;
                contextMenu.IsOpen = true;
            }
        }
    }

Then you have to set the FilteringControl property of the columns which will utilize the custom control.

Example 2: Setting the FilteringControl of the columns

C#

	public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();

            this.AddCustomFilteringControls();
        }

        private void AddCustomFilteringControls()
        {
            foreach (var column in this.gridView.Columns)
            {
                column.FilteringControl = new ExtendedFilteringControl(column);
            }
        }
    }

The examples use the RadGridView setup from its Getting Started article.

If you are using the NoXaml dlls, you should base the style for the custom FilteringControl on the default one for the theme.

See Also