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

Mousedown not firing

2 Answers 1345 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Roger
Top achievements
Rank 1
Roger asked on 26 Aug 2015, 03:02 PM

I notice that sometimes the Mousedown works correctly by selecting the cell being clicked.

Other times, it will scroll back to the top.

I've attempted to add the following code to handle tho Mouse Left Button, and it builds, but doesn't compile.

In constructor:

        gridLineItem.MouseLeftButtonDown += new MouseButtonEventHandler(gridLineItem_MouseDown);

And later on:

        private void gridLineItem_MouseDown(object sender, MouseEventArgs e)
        {
            var foo = 42;
        }

 

If I add a debugger breakpoint inside gridLineItem_MouseDown, it doesn't fire.

The goal is to have the Mouse Left Button consistently select the cell clicked on, and not to scroll to the top.

 

Any suggestions?

2 Answers, 1 is accepted

Sort by
0
Accepted
Ivan Ivanov
Telerik team
answered on 27 Aug 2015, 07:42 AM
Hi,

Can you please confirm what type of element is gridLineItem? Is it a cell? In WPF in is a globally recommended convention that controls should handle the routed events, on which occurrence they execute some logic. Thus if cell gets selected on MouseDown, the resepective event would be handled and will not be "received" by higher level controls. However, in WPF you can subscribe to an event and get notified for its occurrence, even it is handled, like this:
this.AddHandler(MouseLeftButtonDownEvent, new MouseButtonEventHandler(this.OnMouseLeftButtonDown), true);      
 
        void OnMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
         . . .
        }
Can you please confirm, whether this apporach works for you?

Regards,
Ivan Ivanov
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Roger
Top achievements
Rank 1
answered on 27 Aug 2015, 04:52 PM
gridLineItem is a RadGridView control.

Your code DOES work, and calls the MouseDown handler.

Thank you
Tags
GridView
Asked by
Roger
Top achievements
Rank 1
Answers by
Ivan Ivanov
Telerik team
Roger
Top achievements
Rank 1
Share this question
or