Back to Devexpress

DXCollectionView.SwipeItemShowing Event

maui-devexpress-dot-maui-dot-collectionview-dot-dxcollectionview-f88ec885.md

latest3.9 KB
Original Source

DXCollectionView.SwipeItemShowing Event

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.CollectionView

Assembly : DevExpress.Maui.CollectionView.dll

NuGet Package : DevExpress.Maui.CollectionView

Declaration

csharp
public event EventHandler<SwipeItemShowingEventArgs> SwipeItemShowing

Event Data

The SwipeItemShowing event's data class is SwipeItemShowingEventArgs. The following properties provide information specific to this event:

PropertyDescription
CancelGets or sets a value indicating whether the event should be canceled. Inherited from CancelEventArgs.
IsStartSwipeItemGets whether the processed swipe item is about to be displayed on the left side of a DXCollectionView‘s row.
ItemGets the data item that corresponds to the processed DXCollectionView row.
RowHandleGets the handle of the row that contains the item that will be swiped.
SwipeItemGets the swipe item for which the SwipeItemShowing event is raised.

Remarks

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”.

xaml
<dxcv:DXCollectionView x:Name="collectionview" ItemsSource="{Binding OutlookData}" SwipeItemShowing="collectionview_SwipeItemShowing">
    <dxcv:DXCollectionView.ItemTemplate>
        <DataTemplate>
            <dxcv:SwipeContainer>
                <dxcv:SwipeContainer.ItemView>
                    <dx:DXStackLayout Orientation="Vertical" ItemSpacing="6">
                        <Label Text="{Binding Sender}"/>
                        <Label Text="{Binding email}"/>
                    </dx:DXStackLayout>
                </dxcv:SwipeContainer.ItemView>
                <dxcv:SwipeContainer.StartSwipeItems>
                    <dxcv:SwipeContainerItem Caption="Sender Info" BackgroundColor="##26a95e" />
                </dxcv:SwipeContainer.StartSwipeItems>
                <dxcv:SwipeContainer.EndSwipeItems>
                    <dxcv:SwipeContainerItem Caption="Reply" BackgroundColor="#797bff" />
                </dxcv:SwipeContainer.EndSwipeItems>
            </dxcv:SwipeContainer>
        </DataTemplate>
    </dxcv:DXCollectionView.ItemTemplate>
</dxcv:DXCollectionView>
csharp
using DevExpress.Maui.CollectionView;

private void collectionview_SwipeItemShowing(object sender, SwipeItemEventArgs e) {
    DXCollectionView collectionView = sender as DXCollectionView;
    string from = e.Item.ToString();
    if (from.Contains("donotreply") && !e.IsStartSwipeItem)
        e.Cancel = true;
}

See Also

DXCollectionView Class

DXCollectionView Members

DevExpress.Maui.CollectionView Namespace