Xaml
<listView:SfListView.ItemTemplate>
<DataTemplate>
<Grid x:Name="itemTemplateGrid">
<Grid.GestureRecognizers>
<TapGestureRecognizer Command="{Binding Path=BindingContext.OnTap, Source={x:Reference listView}}" CommandParameter="{x:Reference itemTemplateGrid}"/>
</Grid.GestureRecognizers>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="1" />
</Grid.RowDefinitions>
<Grid>
<Label LineBreakMode="NoWrap"
Text="{Binding ContactName}">
</Label>
<Label Grid.Row="1"
Grid.Column="0"
LineBreakMode="NoWrap"
Text="{Binding ContactNumber}"
TextColor="Teal">
</Label>
</Grid>
</DataTemplate>
</listView:SfListView.ItemTemplate>
ViewModel.cs
public class ContactsViewModel
{
public Command<object> OnTap { get; set; }
public ObservableCollection<Contacts> CustomerDetails
{
get;
set;
}
private Random random = new Random();
public ContactsViewModel()
{
this.GetContactDetails(20);
OnTap = new Command<object>(OnTapped);
}
private async void OnTapped(object obj)
{
var itemTemplateGrid = obj as Grid;
var item = itemTemplateGrid.BindingContext as Contacts;
itemTemplateGrid.Opacity = 0;
await itemTemplateGrid.FadeTo(1, 1000, Easing.SinInOut);
this.CustomerDetails.Remove(item);
}
}
|