We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Button in CellTemplate not receiving the first click event until cell is activated

Thread ID:





130047 Apr 18,2017 12:46 PM UTC Apr 21,2017 04:31 AM UTC WPF 3
Tags: SfDataGrid
Sam Chan
Asked On April 18, 2017 12:46 PM UTC


I've loaded a button in the CellTemplate of a GridTemplateColumn. The button has a Click event handler but it is not called when the button is first clicked. Instead the cell containing the button is activated (become selected) after the first click and then the Click event handler is called when the button is clicked again after the cell is activated. How do I enable the button to receive the first click event even when the cell is not activated? For example, the checkbox control of the GridCheckBoxColumn can be checked or unchecked on the first click even when the cell is not activated. I tried:



          <Button syncfusion:VisualContainer.WantsMouseInput="True" Click="Button_Click"/>





Balamurugan Rajaraman [Syncfusion]
Replied On April 19, 2017 12:50 PM UTC

Hi Sam,  
Thank you for contact Syncfusion support.  
We have analyzed your query.  You can achieve your requirement by override the  SetFocus() method in GridCellTemplateRenderer class as like below code sample 
Code Snippet:  
this.datagrid.CellRenderers.Add("TemplateExt"new GridCellTemplateExt());  
public class GridCellTemplateExt : GridCellTemplateRenderer  
    protected override void SetFocus(FrameworkElement uiElement, bool needToFocus)  
        if (!needToFocus)  
In the below sample, we have created the custom column and custom renderer from GridTemplateColumn and focus the element to grid cell.  
Balamurugan R 

Sam Chan
Replied On April 20, 2017 10:51 AM UTC

Hi Balamurugan,

Thank you for the solution. I've adapted the code to achieve the functionality that I need.



Balamurugan Rajaraman [Syncfusion]
Replied On April 21, 2017 04:31 AM UTC

Hi Sam 
Thank you for the update. 
Please let us know further assistance on this. 
Balamurugan R 


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

or the page will be automatically redirected to sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon