Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using Xamarin.Forms;
- namespace ListViewDemoVS
- {
- class MyContentPage : ContentPage
- {
- public MyContentPage()
- {
- Padding = new Thickness(0, Device.OnPlatform(20, 0, 0), 0, 0);
- List<Group> itemsGrouped = new List<Group>
- {
- new Group("Important", new List<ListItem>
- {
- new ListItem { Title = "First", Description = "1st", Source="one.jpg", Price="$100" },
- new ListItem { Title = "Second", Description = "2nd", Source="two.jpg", Price="$200" }
- }),
- new Group("Less Important", new List<ListItem>
- {
- new ListItem { Title = "Third", Description = "3rd", Source="three.jpg", Price="$300" }
- })
- };
- ListView listView = new ListView()
- {
- IsGroupingEnabled = true,
- GroupDisplayBinding = new Binding("Key"),
- ItemTemplate = new DataTemplate(typeof(TextCell))
- {
- Bindings =
- {
- { TextCell.TextProperty, new Binding("Title") },
- { TextCell.DetailProperty, new Binding("Description") }
- }
- },
- GroupHeaderTemplate = new DataTemplate(typeof(HeaderCell)),
- HasUnevenRows = true
- };
- listView.ItemsSource = itemsGrouped;
- /*
- listView.ItemsSource = new ListItem[] {
- new ListItem { Title = "First", Description = "1st", Source="one.jpg", Price="$100" },
- new ListItem { Title = "Second", Description = "2nd", Source="two.jpg", Price="$200" },
- new ListItem { Title = "Third", Description = "3rd", Source="three.jpg", Price="$300" }
- };
- listView.RowHeight = 80;
- listView.BackgroundColor = Color.Black;
- listView.ItemTemplate = new DataTemplate(typeof(ListItemCell));
- */
- this.Content = listView;
- }
- }
- }
Add Comment
Please, Sign In to add comment