How to click a button directly without focus on a CellTemptate of a sfDataGrid
Thank you for contacting Syncfusion Support.
We have analyzed your query. You can set the focus to button without focus on a celltemplate by setting Syncfusion.FocusManagerHelper.FocusedElement to true as shown below,
Code Example:
|
<Syncfusion:GridTemplateColumn> <Syncfusion:GridTemplateColumn.CellTemplate> <DataTemplate> <Button Width="Auto" Syncfusion:FocusManagerHelper.FocusedElement="True" Height="Auto" Click="Button_Click" Content="Call” /> </DataTemplate> </Syncfusion:GridTemplateColumn.CellTemplate> </Syncfusion:GridTemplateColumn> |
Please refer the below KB Link,
KB Link: https://www.syncfusion.com/kb/3206/how-to-edit-sfdatagrid-template-column-by-single-tap
Regards,
Jayapradha
Thank you for contacting Syncfusion Support.
We have analyzed your query. You can set the focus to button without focus on a celltemplate by setting Syncfusion.FocusManagerHelper.FocusedElement to true as shown below,
Code Example:
|
<Syncfusion:GridTemplateColumn> <Syncfusion:GridTemplateColumn.CellTemplate> <DataTemplate> <Button Width="Auto" Syncfusion:FocusManagerHelper.FocusedElement="True" Height="Auto" Click="Button_Click" Content="Call” /> </DataTemplate> </Syncfusion:GridTemplateColumn.CellTemplate> </Syncfusion:GridTemplateColumn> |
Please refer the below KB Link,
KB Link: https://www.syncfusion.com/kb/3206/how-to-edit-sfdatagrid-template-column-by-single-tap
Regards,
Jayapradha
Thank you for your update.
Please let us know if you require any other assistance.
Regards,
Jayapradha
Using syncfusion:FocusManagerHelper.FocusedElement="True" works fine for one of the buttons but clicking the second button works only at the second click.
Is there a solution for this as well?
|
<syncfusion:GridTemplateColumn >
<syncfusion:GridTemplateColumn.CellTemplate>
<DataTemplate>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Button x:Name="button1" Grid.Column="0" Click="button1_Click" Height="20" syncfusion:FocusManagerHelper.FocusedElement="True" Content="B1"/>
<Button x:Name="button2" Grid.Column="1" Click="button2_Click" Height="20" syncfusion:FocusManagerHelper.FocusedElement="True" Content="B2"/>
</Grid>
</DataTemplate>
</syncfusion:GridTemplateColumn.CellTemplate>
</syncfusion:GridTemplateColumn> |
hello Sathiyathanam,
I just download the sample EditingTemplateColumn_WPF-1364933297141210955.zip , and add two messagebox in the two button_click event. When I click the button1, the messagebox show immediately, but when I click button2, the messagebox only show at the second click.
|
this.dataGrid.CellRenderers.Remove("Template");
this.dataGrid.CellRenderers.Add("Template", new GridCellTemplateExt());
public class GridCellTemplateExt : GridCellTemplateRenderer
{
protected override void SetFocus(FrameworkElement uiElement, bool needToFocus)
{
if (!needToFocus)
DataGrid.Focus();
}
} |
- 8 Replies
- 6 Participants
-
MC MARQUANT Cédric
- Apr 10, 2016 06:44 AM UTC
- Feb 7, 2022 03:32 PM UTC