maui-devexpress-dot-maui-dot-datagrid-dot-datagridview-dea63917.md
Fires when a swipe item is about to be shown when a user swipes a row from left to right or from right to left, and allows you to cancel the action.
Namespace : DevExpress.Maui.DataGrid
Assembly : DevExpress.Maui.DataGrid.dll
NuGet Package : DevExpress.Maui.DataGrid
public event EventHandler<SwipeItemShowingEventArgs> SwipeItemShowing
The SwipeItemShowing event's data class is SwipeItemShowingEventArgs. The following properties provide information specific to this event:
| Property | Description |
|---|---|
| Cancel | Gets or sets a value indicating whether the event should be canceled. Inherited from CancelEventArgs. |
| IsStartSwipeItem | Gets whether the processed swipe item is about to be displayed on the left side of a grid row. |
| Item | Gets the data item that corresponds to the processed grid row. |
| RowHandle | Gets the handle of the row that contains the item that is about to be swiped. |
| SwipeItem | Returns the swipe item for which the SwipeItemShowing event is raised. |
For more information about swipe items, refer to the following help topic: Swipe Actions in .NET MAUI Data Grid.
In the markup below, the right-side swipe item is Reply. The code below shows how to prevent this item from showing if the sender’s email contains “donotreply”.
<dxg:DataGridView x:Name="grid" ItemsSource="{Binding OutlookData}" SwipeItemShowing="grid_SwipeItemShowing">
<dxg:DataGridView.StartSwipeItems>
<dxg:GridSwipeItem Caption="Sender Info" BackgroundColor="#26a95e" Tap="OnShowCustomerInfo" />
</dxg:DataGridView.StartSwipeItems>
<dxg:DataGridView.EndSwipeItems>
<dxg:GridSwipeItem Caption="Reply" BackgroundColor="#797bff" Tap="OnReply" />
</dxg:DataGridView.EndSwipeItems>
<dxg:DataGridView.Columns>
<dxg:TextColumn FieldName="From.Email" Caption="From" Width="150">
<dxg:TextColumn.Width>
<OnIdiom x:TypeArguments="GridLength" Phone="110" Tablet="150"/>
</dxg:TextColumn.Width>
</dxg:TextColumn>
<dxg:TextColumn FieldName="Subject" />
<dxg:DateColumn FieldName="Sent" Width="150">
<dxg:DateColumn.IsVisible>
<OnIdiom x:TypeArguments="x:Boolean" Phone="false" Tablet="true"/>
</dxg:DateColumn.IsVisible>
</dxg:DateColumn>
</dxg:DataGridView.Columns>
</dxg:DataGridView>
using DevExpress.Maui.DataGrid;
private void grid_SwipeItemShowing(object sender, SwipeItemEventArgs e) {
DataGridView dataGridView = sender as DataGridView;
string from = (string)dataGridView.GetCellValue(e.RowHandle, "From.Email");
if (from.Contains("donotreply") && !e.IsStartSwipeItem)
e.Cancel = true;
}
See Also