Is there any event which get triggered when an item is added to SfDataGrid in Xamarin Forms?

180 Views Asked by At

I have a SfDataGrid in my Xamarin code base and in that SfDataGrid, there is an Entry for each row. I have to set Focus to the Entry when I add an item. I add Items to the SfDataGrid via a popup. So, are there any events exists to do that? if so, what would be the best way to implement that feature?

<SfDataGrid
 SwipeEnded="DataGrid_SwipeEnded">
     <SfDataGrid.Columns>
          <GridTemplateColumn> 
               <GridTemplateColumn.HeaderTemplate>
               </GridTemplateColumn.HeaderTemplate>
               <GridTemplateColumn.CellTemplate>
                    <DataTemplate>
                         <CustomEntry
                       BindingContextChanged="Entry_ContextChanged"
                       Focused="Entry_Focused">
                         </CustomEntry>
                    </DataTemplate>
               </GridTemplateColumn.CellTemplate>
          </GridTemplateColumn>
     </SfDataGrid.Columns>
</SfDataGrid>
1

There are 1 best solutions below

5
On

Did you read the official document about the sfdatagrid? In the official document, there are all the events can be triggered in the sfdatagrid.

And there is a value changed event seems can meet your requirement:

The SfDataGrid.ValueChanged event will be triggered whenever the current cell’s value has been changed in the GridTextColumn, GridNumericColumn or GridSwitchColumn. This event handler contains the parameter of type ValueChangedEventArgs that contains the following properties.

  1. CellValue : The initial value when current cell entered edit mode.
  2. Column : Gets the current GridColumn that contains the grid cell for which value is edited or changed.
  3. NewValue : The newly edited value to be committed.
  4. RowColumnIndex : The current RowColumnIndex of the grid cell undergoing the value change.
  5. RowData : The RowData of the row that contains the grid cell undergoing the value change.

For more information, you can check the official document.