1

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>
  • If you are adding via a popup, shouldn’t you already know when an item is being added? – Jason Oct 04 '22 at 12:29
  • @Jason Yes, I know. The popup sets the values of the item. and the ViewModel of the page where SfDataGrid situated adds the Item. – ZamrinJameel Oct 04 '22 at 12:35

1 Answers1

1

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.

Liyun Zhang - MSFT
  • 8,271
  • 1
  • 2
  • 14