set hand cursor pointer on cell hover

5 posts, 1 answers
  1. Vitor
    Vitor avatar
    53 posts
    Member since:
    Mar 2016

    Posted 04 Apr Link to this post

    Hello Telerik,

    I am trying to accomplish this

    http://www.telerik.com/forums/gridview-cell-mousehover-hand-cursor

    but for WPF.

    Basically set a hand cursor when it is hovering on the "Name" cell.

    I want to do a link-like visual to my cell (if you could also help on this, much appreciated)

    I have tried to handle events like

    <telerik:GridViewDataColumn DataMemberBinding="{Binding Name}" MouseEnter="GridViewDataColumn_MouseEnter" GotMouseCapture="GridViewDataColumn_GotMouseCapture" MouseMove="GridViewDataColumn_MouseMove" IsMouseCaptureWithinChanged="GridViewDataColumn_IsMouseCaptureWithinChanged"  CellStyleSelector="{StaticResource NameLengthTemplateSelector}"/>

    private void GridViewDataColumn_MouseEnter(object sender, System.Windows.Input.MouseEventArgs e)
    {
     
    }
     
    private void GridViewDataColumn_GotMouseCapture(object sender, System.Windows.Input.MouseEventArgs e)
    {
     
    }
     
    private void GridViewDataColumn_MouseMove(object sender, System.Windows.Input.MouseEventArgs e)
    {
     
    }
     
    private void GridViewDataColumn_IsMouseCaptureWithinChanged(object sender, DependencyPropertyChangedEventArgs e)
    {
     
    }

     

    but none of them gets hit by my breakpoint when I hover my cell

     

     

    please help!

    cheers

  2. Answer
    Yoan
    Admin
    Yoan avatar
    1070 posts

    Posted 04 Apr Link to this post

    Hi Vitor,

    You can use GridView's MouseMove event, but you need to subscribe for it with handledEventsToo since it is handled by RadGridView internally. Then you can check if the originalSource is a child of GridViewCell element like so:
    this.clubsGrid.AddHandler(MouseMoveEvent, new MouseEventHandler(OnMouseMove), true);
        }
     
        private void OnMouseMove(object sender, MouseEventArgs e)
        {
            if ((e.OriginalSource as FrameworkElement).ParentOfType<GridViewCell>() != null)
            {
                Mouse.OverrideCursor = Cursors.Hand;
            }
            else
            {
                Mouse.OverrideCursor = Cursors.Arrow;
            }
        }

    I hope this helps.

    Regards,
    Yoan
    Telerik
    Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
  3. UI for WPF is Visual Studio 2017 Ready
  4. Vitor
    Vitor avatar
    53 posts
    Member since:
    Mar 2016

    Posted 04 Apr in reply to Yoan Link to this post

    Hey Yoan!

     

    Thank you for the quick reply.

    It works for all cells. But how can I make it specifically for the Name column. The first column?

  5. Vitor
    Vitor avatar
    53 posts
    Member since:
    Mar 2016

    Posted 04 Apr in reply to Vitor Link to this post

    actually I could do it by modifying the statement to

    if ((e.OriginalSource as FrameworkElement).ParentOfType<GridViewCell>() != null && (e.OriginalSource as FrameworkElement).ParentOfType<GridViewCell>().Column.Name == "Name")

    looks a bit ugly but that will do it

  6. Yoan
    Admin
    Yoan avatar
    1070 posts

    Posted 04 Apr Link to this post

    Hi Vitor,

    Indeed, you can use the Column property of the GridViewCell element.

    Regards,
    Yoan
    Telerik
    Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
Back to Top
UI for WPF is Visual Studio 2017 Ready