mobilecontrols-devexpress-dot-xamarinforms-dot-datagrid-dot-swipeitem-55c6b487.md
Gets or sets the text displayed within the swipe item.
Namespace : DevExpress.XamarinForms.DataGrid
Assembly : DevExpress.XamarinForms.Grid.dll
NuGet Package : DevExpress.XamarinForms.Grid
[XtraSerializableProperty]
public string Caption { get; set; }
| Type | Description |
|---|---|
| String |
The item’s caption.
|
You can use the Caption property to provide the text description of an action that the swipe item performs when a user taps it. The FontColor property allows you to specify the text color. To customize the caption appearance for all swipe items of the grid, assign a SwipeItemStyle object with the specified FontColor, FontSize, FontFamily and FontAttributes properties to DataGridView.SwipeItemStyle.
You can also use the Image property to display an icon above the swipe item’s caption.
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:
Caption, BackgroundColor and Image properties to customize each button appearance.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:SwipeItem Caption="Customer" BackgroundColor="#797bff" Image="person.png"
Tap="Swipe_ShowCustomerInfo" />
</dxg:DataGridView.StartSwipeItems>
<dxg:DataGridView.EndSwipeItems>
<dxg:SwipeItem Caption="Delete" BackgroundColor="#ff3b30" Image="delete.png"
Tap="Swipe_Delete"/>
</dxg:DataGridView.EndSwipeItems>
<dxg:DataGridView.SwipeItemStyle>
<dxg:SwipeItemStyle Width="100"/>
</dxg:DataGridView.SwipeItemStyle>
</dxg:DataGridView>
using DevExpress.XamarinForms.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);
}
See Also