maui-devexpress-dot-maui-dot-datagrid-5c84f0c8.md
Stores information about an action button shown when a user swipes a data row.
Namespace : DevExpress.Maui.DataGrid
Assembly : DevExpress.Maui.DataGrid.dll
NuGet Package : DevExpress.Maui.DataGrid
public class GridSwipeItem :
VisualElement,
IAppearanceOwner
The following members return GridSwipeItem objects:
Add SwipeItem objects to the DataGridView.StartSwipeItems or DataGridView.EndSwipeItems collections to create swipe buttons in the grid.
This example shows how to extend the grid’s UI with additional elements (buttons) that appear when a user swipes a data row (from left to right or from right to left) and perform custom actions on tap.
Define two swipe actions for rows of the grid bound to the collection of orders:
Start Swipe Item
End Swipe Item
Follow the steps below to implement this functionality:
GridSwipeItem object to the DataGridView.StartSwipeItems or DataGridView.EndSwipeItems collection.Note
The grid performs the first action from its StartSwipeItems collection or last action from EndSwipeItems in response to a full swipe across the row from left to right or from right to left. To change this behavior, use the DataGridView.FullSwipeMode property.
<dxg:DataGridView x:Name="grid" ItemsSource="{Binding Orders}">
<!-- ... -->
<dxg:DataGridView.StartSwipeItems>
<dxg:GridSwipeItem Caption="Customer" BackgroundColor="#797bff" Image="person.png"
Tap="Swipe_ShowCustomerInfo" />
</dxg:DataGridView.StartSwipeItems>
<dxg:DataGridView.EndSwipeItems>
<dxg:GridSwipeItem Caption="Delete" BackgroundColor="#ff3b30" Image="delete.png"
Tap="Swipe_Delete"/>
</dxg:DataGridView.EndSwipeItems>
<dxg:DataGridView.SwipeItemAppearance>
<dxg:SwipeItemAppearance Width="100"/>
</dxg:DataGridView.SwipeItemAppearance>
</dxg:DataGridView>
using DevExpress.Maui.DataGrid;
// ...
private void Swipe_ShowCustomerInfo(object sender, SwipeItemTapEventArgs e) {
var customer = (e.Item as Order).Customer;
string customerName = customer.Name;
string customerPhone = customer.Phone;
DisplayAlert("Customer", "Name: " + customerName + "\n" + "Phone: " + customerPhone, "OK");
}
private void Swipe_Delete(object sender, SwipeItemTapEventArgs e) {
grid.DeleteRow(e.RowHandle);
}
Microsoft.Maui.IFrameworkElement
Microsoft.Maui.Controls.ITabStopElement
System.Object BindableObject Element NavigableElement VisualElement GridSwipeItem
YieldIfNotNull<GridSwipeItem>()
See Also