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
340
Dealing with Multiple XamDataGrid button click events
posted

  I have multiple XamDataGrids in my screen and each of them has a button which is provided by this style -

 

<Style x:Key="BtnStyle" TargetType="{x:Type Button}">

 

<!-- set some color, width etc .. -->      

 

            <EventSetter Event="Click" Handler="btnClick"/>

 

</Style>

 

I cannot have a command for this button due to some constraints so I am handling the normal click event.

 

When the button is clicked, in my code behind I loop though the grids and get the cell whose button was clicked by doing this -  if (dataGrid.ActiveCell != null) {  // do something ... }.

 

The problem is after I clicked a button on 1st grid, if I click on a button in the 2nd grid the ActiveRecord is still treated as the cell originating from the 1st grid. So even if I am in the 2nd grid I get the ActiveRecord as the 1st grid record.

 

Is there any way to reset the active record or any other way to ensure the event is from the grid I have clicked currently?