Advertisement
smeacham

MyContentPage.cs

May 26th, 2016
375
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.45 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 ListViewDemoVS
  10. {
  11.     class MyContentPage : ContentPage
  12.     {
  13.         public MyContentPage()
  14.         {
  15.             Padding = new Thickness(0, Device.OnPlatform(20, 0, 0), 0, 0);
  16.  
  17.             List<Group> itemsGrouped = new List<Group>
  18.             {
  19.                 new Group("Important", new List<ListItem>
  20.                 {
  21.                     new ListItem { Title = "First", Description = "1st", Source="one.jpg", Price="$100" },
  22.                     new ListItem { Title = "Second", Description = "2nd", Source="two.jpg", Price="$200" }
  23.                 }),
  24.                 new Group("Less Important", new List<ListItem>
  25.                 {
  26.                     new ListItem { Title = "Third", Description = "3rd", Source="three.jpg", Price="$300" }
  27.                 })
  28.             };
  29.  
  30.             ListView listView = new ListView()
  31.             {
  32.                 IsGroupingEnabled = true,
  33.                 GroupDisplayBinding = new Binding("Key"),
  34.                 ItemTemplate = new DataTemplate(typeof(ListItemCell)),
  35.                 GroupHeaderTemplate = new DataTemplate(typeof(HeaderCell)),
  36.                 BackgroundColor = Color.Black,
  37.                 HasUnevenRows = true
  38.             };
  39.             listView.ItemsSource = itemsGrouped;
  40.             this.Content = listView;
  41.         }
  42.     }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement