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
|
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xamarin.Forms.CustomAttributes;
using Xamarin.Forms.Internals;
namespace Xamarin.Forms.Controls
{
[Preserve (AllMembers=true)]
[Issue (IssueTracker.Github, 1566, "ListView reuse issue", PlatformAffected.Android)]
public class Issue1566
: ContentPage
{
bool _flag = true;
ObservableCollection<Tuple<string, string>> _collection = new ObservableCollection<Tuple<string, string>>();
void FillTheList()
{
_collection.Clear();
for (int i = 0; i < 100; i++)
{
var item = new Tuple<string, string>(
string.Format("{0} {0} {0} {0} {0} {0}", _flag ? i : 100-i),
string.Format("---- i ----{0} {0} {0} {0} {0} {0}", _flag ? i : 100-i)
);
_collection.Add(item);
}
//flag = !flag;
}
public Issue1566()
{
SearchBar search = new SearchBar();
search.SearchButtonPressed += (sender, e) => FillTheList();
ListView list = new ListView() {
HorizontalOptions = LayoutOptions.FillAndExpand,
VerticalOptions = LayoutOptions.FillAndExpand,
HasUnevenRows = true,
ItemsSource = _collection,
ItemTemplate = new DataTemplate(typeof(CellTemplate))
};
Label info = new Label() {
Text = "Type something into searchbox and press search. Then swipe the list. Rows are mixed. It's important to have keyboard visible!!!"
};
StackLayout root = new StackLayout() {
HorizontalOptions = LayoutOptions.FillAndExpand,
VerticalOptions = LayoutOptions.FillAndExpand,
Children =
{
search,
list,
info,
}
};
Content = root;
}
class CellTemplate : ViewCell
{
public CellTemplate()
{
Label cellLabel = new Label() {
HorizontalOptions = LayoutOptions.FillAndExpand,
};
cellLabel.SetBinding(Label.TextProperty, new Binding("Item1", BindingMode.OneWay));
StackLayout root = new StackLayout() {
Children =
{
cellLabel
}
};
View = root;
}
}
}
}
|