Thread ID: |
Created: |
Updated: |
Platform: |
Replies: |
143124 | Mar 5,2019 12:44 PM UTC | Mar 7,2019 10:08 AM UTC | Xamarin.Forms | 3 |
![]() |
Tags: SfListView |
XAML:
<Grid>
<Button Text="Add Item" Command="{Binding TapCommand}" CommandParameter="{x:Reference listView}"/>
<syncfusion:SfListView/>
</Grid>
ViewModel:
public class ContactsViewModel : INotifyPropertyChanged
{
public Command<object> TapCommand { get; set; }
public ContactsViewModel()
{
contactsinfo = new ObservableCollection<Contacts>();
TapCommand = new Command<object>(OnTapped);
}
private void OnTapped(object obj)
{
listView = obj as SfListView;
Contacts newContact = new Contacts();
newContact.ContactName = "Jonas";
contactsinfo.Add(newContact);
int newIndex = listView.DataSource.DisplayItems.IndexOf(newContact);
listView.LayoutManager.ScrollToRowIndex(newIndex, true);
}
}
|
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.