-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
Bugzilla21501.cs
57 lines (48 loc) · 1.3 KB
/
Bugzilla21501.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
using System;
using Xamarin.Forms.CustomAttributes;
using System.Collections.Generic;
using Xamarin.Forms.Internals;
using NUnit.Framework;
namespace Xamarin.Forms.Controls.Issues
{
#if UITEST
[Category(Core.UITests.UITestCategories.Bugzilla)]
#endif
[Preserve(AllMembers = true)]
[Issue(IssueTracker.Bugzilla, 21501, "ListView: Button in ItemTemplate breaks SelectedItem", PlatformAffected.Android)]
public class Bugzilla21501 : ContentPage
{
public Bugzilla21501()
{
var stringList = new List<string>() { "abc", "xyz", "todo" };
var resultLabel = new Label() { Text = "A" };
var listView = new ListView();
listView.ItemsSource = stringList;
listView.ItemTemplate = new DataTemplate(() =>
{
var label = new Label();
label.SetBinding(Label.TextProperty, ".");
var button = new Button() { Text = "Test" };
return new ViewCell
{
View = new StackLayout
{
Padding = new Thickness(0, 5),
Orientation = StackOrientation.Horizontal,
Children = { label, button }
}
};
});
listView.ItemSelected += (sender, args) =>
{
resultLabel.Text = resultLabel.Text + "!";
};
var layout = new StackLayout()
{
Orientation = StackOrientation.Vertical,
Children = { listView, resultLabel }
};
Content = layout;
}
}
}