New to Telerik UI for WPF? Download free 30-day trial

Change Hand Cursor Icon to Loading Icon Upon Clicking on Filter in RadGridView Column Header

Environment

Product Version 2023.2.718
Product RadGridView for WPF

Description

How to change the mouse cursor icon on click over the filter drop down button of the RadGridView column headers (the funnel icon).

Solution

You can use the MouseLeftButtonDown event of the RadGridView control to get the FilterDropDown control. Then you can override the cursor on click.

public MainWindow() 
{ 
    InitializeComponent();   
    this.gridView.AddHandler(RadGridView.MouseLeftButtonDownEvent, new MouseButtonEventHandler(OnGridViewMouseLeftButtonDown), true); 
} 
 
private void OnGridViewMouseLeftButtonDown(object sender, MouseButtonEventArgs e) 
{ 
    var clickedElement = (FrameworkElement)e.OriginalSource; 
    var filteringDropDown = clickedElement.ParentOfType<FilteringDropDown>(); 
    if (filteringDropDown != null) 
    { 
        if (!filteringDropDown.IsDropDownOpen) 
        { 
            Mouse.OverrideCursor = Cursors.ArrowCD;                   
 
            // execute this code only if you want to return the cursor back to normal when the drop down content is opened 
            Dispatcher.BeginInvoke(new Action(() => 
            { 
                Mouse.OverrideCursor = null; 
            }), System.Windows.Threading.DispatcherPriority.SystemIdle); 
        } 
        else 
        { 
            Mouse.OverrideCursor = null; 
        } 
    } 
} 
In this article