Skip to content

Commit c784c96

Browse files
committed
Updated the README.md file.
1 parent ac14614 commit c784c96

File tree

1 file changed

+66
-0
lines changed

1 file changed

+66
-0
lines changed

README.md

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,72 @@
22

33
This example demonstrates how to swipe an item programmatically in xamarin.forms listview.
44

5+
## Sample
6+
7+
```xaml
8+
<StackLayout>
9+
<Grid HeightRequest="50">
10+
<Button x:Name="RightSwipe" Text="Right Swipe Button" />
11+
<Button x:Name="LeftSwipe" Text="Left Swipe Button" Grid.Column="1"/>
12+
</Grid>
13+
<listView:SfListView x:Name="listView" ItemSize="70" SelectionMode="Single" AllowSwiping="True" ItemSpacing="0,0,5,0" >
14+
15+
<listView:SfListView.LeftSwipeTemplate>
16+
<DataTemplate>
17+
<ViewCell>
18+
<ViewCell.View>
19+
<Grid BackgroundColor="SlateBlue" HorizontalOptions="Fill" VerticalOptions="Fill">
20+
<Label Text="Left Swipe Template" TextColor="White" VerticalOptions="Center" HorizontalOptions="Center"/>
21+
</Grid>
22+
</ViewCell.View>
23+
</ViewCell>
24+
</DataTemplate>
25+
</listView:SfListView.LeftSwipeTemplate>
26+
27+
<listView:SfListView.RightSwipeTemplate>
28+
<DataTemplate>
29+
<ViewCell>
30+
<ViewCell.View>
31+
<Grid BackgroundColor="SlateBlue" HorizontalOptions="Fill" VerticalOptions="Fill">
32+
<Label Text="Right Swipe Template" TextColor="White" VerticalOptions="Center"/>
33+
</Grid>
34+
</ViewCell.View>
35+
</ViewCell>
36+
</DataTemplate>
37+
</listView:SfListView.RightSwipeTemplate>
38+
39+
<listView:SfListView.ItemTemplate>
40+
<DataTemplate>
41+
<ViewCell>
42+
<ViewCell.View>
43+
<code>
44+
. . .
45+
. . .
46+
<code>
47+
</ViewCell.View>
48+
</ViewCell>
49+
</DataTemplate>
50+
</listView:SfListView.ItemTemplate>
51+
</listView:SfListView>
52+
</StackLayout>
53+
54+
Code Behind :
55+
Button rightSwipeButton = bindable.FindByName<Button>("RightSwipe");
56+
Button leftSwipeButton = bindable.FindByName<Button>("LeftSwipe");
57+
rightSwipeButton.Clicked += RightSwipeButton_Clicked;
58+
leftSwipeButton.Clicked += LeftSwipeButton_Clicked;
59+
60+
private void LeftSwipeButton_Clicked(object sender, EventArgs e)
61+
{
62+
ListView.SwipeItem(viewModel.contactsinfo[1], 200);
63+
}
64+
65+
private void RightSwipeButton_Clicked(object sender, EventArgs e)
66+
{
67+
ListView.SwipeItem(viewModel.contactsinfo[1], -150);
68+
}
69+
```
70+
571
## Requirements to run the demo
672

773
* [Visual Studio 2017](https://visualstudio.microsoft.com/downloads/) or [Visual Studio for Mac](https://visualstudio.microsoft.com/vs/mac/)

0 commit comments

Comments
 (0)