-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
GitHub1567.cs
109 lines (100 loc) · 2.71 KB
/
GitHub1567.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
using Xamarin.Forms.CustomAttributes;
using Xamarin.Forms.Internals;
using System.Windows.Input;
using System.Collections.ObjectModel;
using System.Threading;
using System.Threading.Tasks;
using System;
#if UITEST
using Xamarin.UITest;
using NUnit.Framework;
#endif
namespace Xamarin.Forms.Controls.Issues
{
#if UITEST
[NUnit.Framework.Category(Core.UITests.UITestCategories.Github5000)]
#endif
[Preserve(AllMembers = true)]
[Issue(IssueTracker.Github, 1567, "NRE using TapGestureRecognizer on cell with HasUnevenRows", PlatformAffected.iOS, issueTestNumber: 1)]
public class GitHub1567 : TestContentPage // or TestMasterDetailPage, etc ...
{
ICommand SomeCommand;
ObservableCollection<LocalIem> LocalList { get; set; } = new ObservableCollection<LocalIem>();
protected override async void Init()
{
// Initialize ui here instead of ctor
var btn = new Button
{
AutomationId = "btnFillData",
Text = "FILL DATA",
Command = new Command(async () => { await FillData(); })
};
var lst = new ListView(ListViewCachingStrategy.RecycleElement)
{
Header = btn,
HasUnevenRows = true,
RowHeight = -1,
SeparatorVisibility = SeparatorVisibility.None,
ItemsSource = LocalList,
ItemTemplate = new DataTemplate(typeof(CustomCell))
};
Content = lst;
this.BindingContext = this;
SomeCommand = new Command(SomeCommandAction);
await FillData();
}
[Preserve(AllMembers = true)]
class CustomCell : ViewCell
{
public CustomCell()
{
var lbl = new Label { FontSize = 14 };
lbl.SetBinding(Label.TextProperty, "Value1");
var grd = new Grid();
var boxView = new BoxView
{
BackgroundColor = Color.Transparent,
HorizontalOptions = LayoutOptions.FillAndExpand,
VerticalOptions = LayoutOptions.FillAndExpand
};
var gesture = new TapGestureRecognizer();
gesture.SetBinding(TapGestureRecognizer.CommandProperty, "SomeCommand");
boxView.GestureRecognizers.Add(gesture);
grd.Children.Add(lbl);
grd.Children.Add(boxView);
View = grd;
}
}
void SomeCommandAction(object obj)
{
}
async Task FillData()
{
await Task.Factory.StartNew(async () =>
{
await Task.Delay(100);
LocalList.Clear();
for (int i = 0; i < 100; i++)
{
LocalList.Add(new LocalIem()
{
Value1 = DateTime.UtcNow.Ticks.ToString(),
});
}
}, CancellationToken.None, TaskCreationOptions.LongRunning, TaskScheduler.Default);
}
[Preserve(AllMembers = true)]
class LocalIem
{
public string Value1 { get; set; }
}
#if UITEST
[Test]
public void GitHub1567Test()
{
RunningApp.WaitForElement(q => q.Marked("btnFillData"));
RunningApp.Tap(q => q.Marked("btnFillData"));
}
#endif
}
}