This is a migrated thread and some comments may be shown as answers.

set hand cursor pointer on cell hover

4 Answers 529 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Vitor
Top achievements
Rank 1
Vitor asked on 04 Apr 2016, 09:18 AM

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

4 Answers, 1 is accepted

Sort by
0
Accepted
Yoan
Telerik team
answered on 04 Apr 2016, 10:11 AM
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.
0
Vitor
Top achievements
Rank 1
answered on 04 Apr 2016, 10:52 AM
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?

0
Vitor
Top achievements
Rank 1
answered on 04 Apr 2016, 11:53 AM

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

0
Yoan
Telerik team
answered on 04 Apr 2016, 12:35 PM
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.
Tags
GridView
Asked by
Vitor
Top achievements
Rank 1
Answers by
Yoan
Telerik team
Vitor
Top achievements
Rank 1
Share this question
or