Tvd
Tvd

Reputation: 4601

WPF : Know which Control is clicked on Datagrid

I have a DataGrid bounded to OservableCollection populated cols and rows dynamically. The DataGrid's row has couple of buttons. On each button a method is called (have implemented AddHandler while generating columns).

In the handler method, I can get which row was selected. I want to know the button of which column was selected. Based on that only I can take action and open respective windows.

How do I know which button of the row was selected ?

Upvotes: 1

Views: 210

Answers (1)

Tvd
Tvd

Reputation: 4601

I get the column using :

int col = myDataGrid.CurrentCell.Column.DisplayIndex;
int row = seivesTorGrid.SelectedIndex; 

Based on this I am able to code respective actions.

Upvotes: 1

Related Questions