HOW TO GET SINGLE CLICK EVENT ON IMAGE IN COLUMN OF DEVEXPRESS GRID CONTROL USING WPF?

jacob rasel

Total Post:88

Points:616
Posted by  jacob rasel
WPF 
WPF
 4514  View(s)
Ratings:
Rate this:

I have Navigation bar control and one NavBar Group contains the grid control. I want to get the single click event on particular image which is in one column of grid control and on image click event I have to show the pop-up for some menu options.

I’m using the grid control’s preview mouse left button up event to get the click but it’s not working because the grid control resides in Navbar control.

Basically my problem is that I am not able to get the single click on image which is on column of grid control and grid column itself resides in one Navbar group of NavBar Control.

This link has my demo project.

Any help will be appreciated.

  1. Sumit Kesarwani

    Post:378

    Points:2694
    Re: How to get single click event on image in column of DevExpress Grid Control using wpf?

    Hi Jacob,

    The below code will solve your problem:-

    private void gridControl1_PreviewMouseDown(object sender, MouseButtonEventArgs e) {

    TableViewHitInfo hit = tableView1.CalcHitInfo(e.OriginalSource as DependencyObject);

    if (hit.InRowCell) {

     gridControl1.View.FocusedRowHandle = hit.RowHandle;

       if (e.ClickCount == 1)

        { 

          if (e.XButton1 == MouseButtonState.Released)

            {

               if (hit.Column.FieldName == "number")

                   {

                          var row = gridControl1.GetFocusedRow();

                          data d = (data)row;

                          MessageBox.Show(d.number.ToString());

                          x = d.number;

                        }

                        if (e.RightButton == MouseButtonState.Pressed)

                        {

                            if (hit.Column.FieldName == "image")

                            {

                                gridControl1.View.FocusedRowHandle = hit.RowHandle;

                                var row = gridControl1.GetFocusedRow();

                                data d = (data)row;

                                x = d.number;

                                popup.StaysOpen = true;

                                popup.IsEnabled = true;

                                popup.IsOpen = true;

                            }

                        }

                    }

    }

    }

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!