Category / Section
How to cancel swipe programmatically ?
1 min read
SfDataGrid allows you to cancel the swipe programmatically by calling the SfDataGrid.ResetSwipeOffset method in SfDataGrid.SwipeEnded event.
The below code example illustrates how to cancel the swiping programmatically by calling the ResetSwipeOffset method.
<syncfusion:SfDataGrid x:Name="datagrid" ColumnSizer="Star" AutoGenerateColumns="True" AllowSwiping="True" ItemsSource="{Binding OrdersInfo}" SwipeEnded="Datagrid_SwipeEnded"> <syncfusion:SfDataGrid.LeftSwipeTemplate> <DataTemplate> <Grid BackgroundColor="Blue"> <Label Text ="EDIT" HorizontalTextAlignment="Start" VerticalTextAlignment="Center" LineBreakMode ="NoWrap" BackgroundColor="Transparent" TextColor ="White" /> </Grid> </DataTemplate> </syncfusion:SfDataGrid.LeftSwipeTemplate> <syncfusion:SfDataGrid.RightSwipeTemplate> <DataTemplate> <Grid BackgroundColor="Red"> <Label FontSize="15" HorizontalTextAlignment ="Center" Text ="Deleted" TextColor ="White" VerticalTextAlignment ="Center" LineBreakMode ="NoWrap" /> </Grid> </DataTemplate> </syncfusion:SfDataGrid.RightSwipeTemplate> </syncfusion:SfDataGrid>
private void Datagrid_SwipeEnded(object sender, SwipeEndedEventArgs e) { datagrid.ResetSwipeOffset(); }
Sample Link:
How to cancel the swipe programmatically?