Articles in this section
Category / Section

How to edit DataGrid Template column by single tap in Silverlight?

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>

 

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