2016-03-22 23:02:25 +03:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Collections.ObjectModel;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
using Xamarin.Forms.CustomAttributes;
|
2016-04-26 18:20:55 +03:00
|
|
|
|
using Xamarin.Forms.Internals;
|
2016-03-22 23:02:25 +03:00
|
|
|
|
|
|
|
|
|
namespace Xamarin.Forms.Controls.TestCasesPages
|
|
|
|
|
{
|
|
|
|
|
[Preserve (AllMembers=true)]
|
|
|
|
|
[Issue (IssueTracker.Github, 1590, "ListView.IsGroupingEnabled results ins ArguementOutOfRangeException", PlatformAffected.Android)]
|
|
|
|
|
public class Issue1590 : ContentPage
|
|
|
|
|
{
|
|
|
|
|
ListView _listView;
|
|
|
|
|
|
|
|
|
|
public Issue1590()
|
|
|
|
|
{
|
|
|
|
|
var vm = new RootPageViewModel();
|
|
|
|
|
Content = BuildListView(vm);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
StackLayout BuildListView(RootPageViewModel viewModel)
|
|
|
|
|
{
|
|
|
|
|
var headerTemplate = new DataTemplate(typeof(ModuleMediaListHeaderTemplate));
|
|
|
|
|
headerTemplate.CreateContent();
|
|
|
|
|
|
|
|
|
|
var itemTemplate = new DataTemplate(typeof(ModuleMediaListItemTemplate));
|
|
|
|
|
itemTemplate.CreateContent();
|
|
|
|
|
|
|
|
|
|
_listView = new ListView
|
|
|
|
|
{
|
|
|
|
|
ItemsSource = viewModel.MediaSections,
|
|
|
|
|
IsGroupingEnabled = true,
|
|
|
|
|
GroupDisplayBinding = new Binding("SectionName"),
|
|
|
|
|
HasUnevenRows = false,
|
|
|
|
|
GroupHeaderTemplate = headerTemplate,
|
|
|
|
|
ItemTemplate = itemTemplate
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return new StackLayout { Children = { _listView } };
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Preserve (AllMembers=true)]
|
|
|
|
|
public class RootPageViewModel
|
|
|
|
|
{
|
|
|
|
|
public IEnumerable MediaSections
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
var titles = new[] {"First", "Second", "Third", "Forth", "Fifth"};
|
|
|
|
|
|
|
|
|
|
return titles.Select(section => new MediaListSection(section)
|
|
|
|
|
{
|
|
|
|
|
new FooViewModel {Title = "Foo", Description = "description for foo"},
|
|
|
|
|
new FooViewModel {Title = "Bar", Description = "description for bar"},
|
|
|
|
|
new FooViewModel {Title = "Baz", Description = "description for baz"},
|
|
|
|
|
new FooViewModel {Title = "Fiz", Description = "description for fiz"},
|
|
|
|
|
new FooViewModel {Title = "Buz", Description = "description for buz"},
|
|
|
|
|
}).ToList();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Preserve (AllMembers=true)]
|
|
|
|
|
public class MediaListSection : ObservableCollection<FooViewModel>
|
|
|
|
|
{
|
|
|
|
|
public string SectionName { get; private set; }
|
|
|
|
|
|
|
|
|
|
public MediaListSection(string sectionName)
|
|
|
|
|
{
|
|
|
|
|
SectionName = sectionName;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Preserve (AllMembers=true)]
|
|
|
|
|
public class FooViewModel
|
|
|
|
|
{
|
|
|
|
|
public string Title { get; set; }
|
|
|
|
|
public string Description { get; set; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Preserve (AllMembers=true)]
|
|
|
|
|
public class ModuleMediaListItemTemplate : ViewCell
|
|
|
|
|
{
|
|
|
|
|
public ModuleMediaListItemTemplate()
|
|
|
|
|
{
|
2016-04-11 19:50:28 +03:00
|
|
|
|
#pragma warning disable 618
|
2016-03-22 23:02:25 +03:00
|
|
|
|
var title = new Label { YAlign = TextAlignment.Center };
|
2016-04-11 19:50:28 +03:00
|
|
|
|
#pragma warning restore 618
|
2016-03-22 23:02:25 +03:00
|
|
|
|
title.SetBinding(Label.TextProperty, new Binding("Title", BindingMode.OneWay));
|
|
|
|
|
|
2016-04-11 19:50:28 +03:00
|
|
|
|
#pragma warning disable 618
|
2016-03-22 23:02:25 +03:00
|
|
|
|
var description = new Label { YAlign = TextAlignment.Center };
|
2016-04-11 19:50:28 +03:00
|
|
|
|
#pragma warning restore 618
|
2016-03-22 23:02:25 +03:00
|
|
|
|
description.SetBinding(Label.TextProperty, new Binding("Description", BindingMode.OneWay));
|
|
|
|
|
|
|
|
|
|
View = new StackLayout
|
|
|
|
|
{
|
|
|
|
|
Orientation = StackOrientation.Horizontal,
|
|
|
|
|
Padding = new Thickness(8),
|
|
|
|
|
Children = { title, description }
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Preserve (AllMembers=true)]
|
|
|
|
|
public class ModuleMediaListHeaderTemplate : ViewCell
|
|
|
|
|
{
|
|
|
|
|
public ModuleMediaListHeaderTemplate()
|
|
|
|
|
{
|
2016-04-11 19:50:28 +03:00
|
|
|
|
#pragma warning disable 618
|
2016-03-22 23:02:25 +03:00
|
|
|
|
var title = new Label { TextColor = Color.White, YAlign = TextAlignment.Center };
|
2016-04-11 19:50:28 +03:00
|
|
|
|
#pragma warning restore 618
|
2016-03-22 23:02:25 +03:00
|
|
|
|
title.SetBinding(Label.TextProperty, new Binding("SectionName", BindingMode.OneWay));
|
|
|
|
|
|
|
|
|
|
View = new StackLayout
|
|
|
|
|
{
|
|
|
|
|
Padding = new Thickness(8, 0),
|
|
|
|
|
BackgroundColor = Color.FromHex("#999999"),
|
|
|
|
|
Orientation = StackOrientation.Horizontal,
|
|
|
|
|
Children = { title },
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|