blob: 7489c9c6fe7c230832013c18432a38c32a1e4ed2 (
plain)
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
|
using System;
using Xamarin.Forms.CustomAttributes;
using System.Collections.Generic;
using Xamarin.Forms.Internals;
namespace Xamarin.Forms.Controls
{
[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;
}
}
}
|