Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
695
CellClicked and CellDoubleClicked
posted

Hi,

I need to do two different things when a row is clicked vs double clicked. When clicked, I show a detail record, when double clicked, I pop it up to a new window. When I double click it shouldn't register a click event, but it does, so it both pops up the detail record + shows it in the page (which I don't want). Is this a bug and if so, is there a workaround?

thanks,

greg

Parents
  • 40030
    Verified Answer
    Offline posted

    Hi Greg ,

    So, as you probably know, there isn't a click, let alone a doubleClick event on framework elements in SL. Thus, we've had to create our own. We raise the click event on mouse up, and the double click if mouse down fires twice within a certain period time, around 400 ms. 

    Since, we don't want to delay the click for 400 ms, we can't  really distinguish between the 2, thus they both fire. 

    However, if you're willing to do so, then it's completely possible to handle this from your end, by using a DispatcherTimer.

    timer.Interval = TimeSpan.FromMilliseconds(400);

                timer.Tick += new EventHandler((sender, args) =>

                {

                    // Add your Single Click code here:

                    timer.Stop();

                });

     void DataGrid1_CellDoubleClicked(object sender, CellClickedEventArgs e)

            {

                timer.Stop();

                // Add your DoubleClick logic here. 

            }

     void DataGrid1_CellClicked(object sender, CellClickedEventArgs e)

            {

                timer.Start();

            }

    Hope this helps, 

    -SteveZ

Reply Children
No Data