Articles in this section
Category / Section

How to edit DataGrid Template column by single tap in WPF application?

1 min read

When you use the GridTemplateColumn while entering Edit mode on a single tap, SfDataGrid cannot focus on a particular UIElement defined inside GridTemplateColumn.EditTemplate, but rest of the columns go for Edit mode in a single click. Hence, in order to enter the Edit mode on a single tap, you need to set focus to the control loaded inside the DataTemplate, explicitly. To set the focus to the control loaded inside the DataTemplate you can use the attached property FocusManagerHelper.FocusedElement.

The attached property FocusManagerHelper.FocusedElement gives focus to a particular UIElement loaded inside the DataTemplate. So, you can enter the Edit mode in a single tap.

You can refer the following code example.

XAML

<Window x:Class="DetailsViewSimple.MainWindow"
                xmlns:syncfusion="http://schemas.syncfusion.com/wpf" >
   <syncfusion:SfDataGrid x:Name="dataGrid"
                               AllowEditing="True"
                               EditTrigger="OnTap"
                              ItemsSource="{Binding GDCSource}" >
      <syncfusion:GridTemplateColumn HeaderText="GrandTotal" MappingName="GrandTotal" >
          <syncfusion:GridTemplateColumn.CellTemplate>
                    <DataTemplate>
                            <TextBlock Text="{Binding GrandTotal}"/>
                    </DataTemplate>
          /syncfusion:GridTemplateColumn.CellTemplate>
          <syncfusion:GridTemplateColumn.EditTemplate>
                    <DataTemplate>
                            <TextBox Text="{Binding GrandTotal, Mode=TwoWay}" syncfusion:FocusManagerHelper.FocusedElement="True" />
                    </DataTemplate>
          </syncfusion:GridTemplateColumn.EditTemplate>
     </syncfusion:GridTemplateColumn>
   </syncfusion:SfDataGrid>
</Window>

 

Conclusion

I hope you enjoyed learning about how to edit WPF DataGrid template column by single tap.

You can refer to our WPF DataGrid feature tour page to know about its other groundbreaking feature representations. You can also explore our WPF DataGrid documentation to understand how to create and manipulate data.

For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.

If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forumsDirect-Trac, or feedback portal. We are always happy to assist you!

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied