-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
Issue3524.cs
78 lines (69 loc) · 1.74 KB
/
Issue3524.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
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Text;
using System.Threading.Tasks;
using Xamarin.Forms.CustomAttributes;
using Xamarin.Forms.Internals;
#if UITEST
using Xamarin.UITest;
using NUnit.Framework;
using Xamarin.Forms.Core.UITests;
#endif
namespace Xamarin.Forms.Controls.Issues
{
[Preserve(AllMembers = true)]
[Issue(IssueTracker.Github, 3524, "ICommand binding from a TapGestureRecognizer on a Span doesn't work")]
#if UITEST
[NUnit.Framework.Category(Core.UITests.UITestCategories.Github5000)]
[NUnit.Framework.Category(UITestCategories.Gestures)]
#endif
public class Issue3524 : TestContentPage
{
const string kText = "Click Me To Increment";
public Command TapCommand { get; set; }
public String Text { get; set; } = kText;
protected override void Init()
{
int i = 0;
FormattedString formattedString = new FormattedString();
var span = new Span() { AutomationId = kText };
span.Text = kText;
var tapGesture = new TapGestureRecognizer();
tapGesture.SetBinding(TapGestureRecognizer.CommandProperty, "TapCommand");
span.GestureRecognizers.Add(tapGesture);
formattedString.Spans.Add(span);
BindingContext = this;
var label = new Label()
{
AutomationId = kText,
HorizontalOptions = LayoutOptions.Center
};
label.FormattedText = formattedString;
TapCommand = new Command(() =>
{
i++;
span.Text = $"{kText}: {i}";
});
Content = new ContentView()
{
Content = new StackLayout()
{
Children =
{
label
}
}
};
}
#if UITEST
[Test]
public void SpanGestureCommand()
{
RunningApp.WaitForElement(kText);
RunningApp.Tap(kText);
RunningApp.WaitForElement($"{kText}: 1");
}
#endif
}
}