Thread ID: |
Created: |
Updated: |
Platform: |
Replies: |
150870 | Jan 22,2020 01:58 PM UTC | Jan 23,2020 08:52 AM UTC | Xamarin.Forms | 1 |
![]() |
Tags: SfListView |
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);
}
}
|
This post will be permanently deleted. Are you sure you want to continue?
Sorry, An error occured while processing your request. Please try again later.
This page will automatically be redirected to the sign-in page in 10 seconds.