smeacham

DrilldownListViewByItem.cs

Jun 2nd, 2016
342
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.18 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. using Xamarin.Forms;
  8.  
  9. namespace DrilldownListViewDemoVS
  10. {
  11.     class DrilldownListViewByItem : ContentPage
  12.     {
  13.         public DrilldownListViewByItem()
  14.         {
  15.             Title = "Drilldown List Using ListView";
  16.  
  17.             ListView listView = new ListView();
  18.  
  19.             listView.ItemsSource = new ListItem[] {
  20.                 new ListItem { Title = "First", Description = "1st item" },
  21.                 new ListItem { Title = "Second", Description = "2nd item" },
  22.                 new ListItem { Title = "Third", Description = "3rd item" }
  23.             };
  24.  
  25.             listView.ItemTemplate = new DataTemplate(typeof(TextCell));
  26.             listView.ItemTemplate.SetBinding(TextCell.TextProperty, "Title");
  27.  
  28.             listView.ItemTapped += async (sender, e) =>
  29.             {
  30.                 var item = e.Item as ListItem;
  31.                 if (item == null) return;
  32.                 await Navigation.PushAsync(new DetailPage(item));
  33.                 listView.SelectedItem = null;
  34.             };
  35.  
  36.             this.Content = listView;
  37.         }
  38.     }
  39. }
Add Comment
Please, Sign In to add comment