summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue2953.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue2953.cs')
-rw-r--r--Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue2953.cs89
1 files changed, 89 insertions, 0 deletions
diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue2953.cs b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue2953.cs
new file mode 100644
index 00000000..28aed46e
--- /dev/null
+++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue2953.cs
@@ -0,0 +1,89 @@
+´╗┐using System;
+
+using Xamarin.Forms.CustomAttributes;
+using System.Collections.ObjectModel;
+
+#if UITEST
+using Xamarin.UITest;
+using NUnit.Framework;
+#endif
+
+namespace Xamarin.Forms.Controls
+{
+ [Preserve (AllMembers = true)]
+ [Issue (IssueTracker.Github, 2953, "GroupHeaderCells disappear when item is removed from a group in ListView (iOS only) ")]
+ public class Issue2953 : TestContentPage
+ {
+ protected override void Init ()
+ {
+ var items = new ObservableCollection<GroupedItems> () {
+ new GroupedItems ("Header 1") { "1.1", "1.2", "1.3" },
+ new GroupedItems ("Header 2") { "2.1", "2.2", "2.3" },
+ new GroupedItems ("Header 3") { "3.1", "3.2", "3.3" },
+ new GroupedItems ("Header 4") { "4.1", "4.2", "4.3" },
+ };
+
+ var listview = new ListView {
+ HasUnevenRows = true,
+ IsGroupingEnabled = true
+ };
+
+ listview.GroupHeaderTemplate = new DataTemplate
+ (typeof(HeaderCell));
+ listview.ItemTemplate = new DataTemplate (typeof(ItemCell));
+ listview.ItemsSource = items;
+
+ var btnRemove = new Button () { Text = "Remove", AutomationId="btnRemove" };
+ btnRemove.Clicked += delegate {
+ if (items[1].Count > 0) {
+ items[1].RemoveAt(0);
+ }
+ };
+
+ Content = new StackLayout {
+ Orientation = StackOrientation.Vertical,
+ Children = { listview, btnRemove }
+ };
+ }
+
+ [Preserve (AllMembers = true)]
+ internal class GroupedItems : ObservableCollection<string> {
+ public GroupedItems (string groupName) { GroupName = groupName; }
+ public string GroupName { get; private set; }
+ }
+
+ [Preserve (AllMembers = true)]
+ internal class HeaderCell : ViewCell
+ {
+ public HeaderCell () {
+ Height = 44;
+ var label = new Label { BackgroundColor = Color.Pink };
+ label.SetBinding (Label.TextProperty, "GroupName");
+ View = label;
+ }
+ }
+
+ [Preserve (AllMembers = true)]
+ internal class ItemCell : ViewCell
+ {
+ public ItemCell () {
+ var label = new Label { BackgroundColor = Color.Aqua };
+ label.SetBinding (Label.TextProperty, ".");
+ View = label;
+ }
+ }
+
+#if UITEST
+ [Test]
+ public void Issue2953Test ()
+ {
+ RunningApp.Screenshot ("I am at Issue 2953");
+ RunningApp.WaitForElement (q => q.Marked ("Header 3"));
+ RunningApp.Screenshot ("I see the Header 3");
+ RunningApp.Tap (q => q.Marked ("btnRemove"));
+ RunningApp.WaitForElement (q => q.Marked ("Header 3"));
+ RunningApp.Screenshot ("I still see the Header 3");
+ }
+#endif
+ }
+}