Mousedown not firing

3 posts, 1 answers
  1. Roger
    Roger avatar
    3 posts
    Member since:
    Jun 2009

    Posted 26 Aug 2015 Link to this post

    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. Answer
    Ivan Ivanov
    Ivan Ivanov avatar
    1201 posts

    Posted 27 Aug 2015 Link to this post


    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?

    Ivan Ivanov
    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
  3. Roger
    Roger avatar
    3 posts
    Member since:
    Jun 2009

    Posted 27 Aug 2015 in reply to Ivan Ivanov Link to this post

    gridLineItem is a RadGridView control.

    Your code DOES work, and calls the MouseDown handler.

    Thank you
Back to Top