-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
Issue1326.cs
76 lines (67 loc) · 2.25 KB
/
Issue1326.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
using System;
using System.Collections.Generic;
using Xamarin.Forms.CustomAttributes;
using Xamarin.Forms.Internals;
namespace Xamarin.Forms.Controls.Issues
{
#if UITEST
[NUnit.Framework.Category(Core.UITests.UITestCategories.Github5000)]
#endif
[Preserve(AllMembers = true)]
[Issue(IssueTracker.Github, 1326, "ListView word wrap in Label causing ViewCells to overlap", PlatformAffected.iOS)]
public class Issue1326 : TestContentPage
{
private MyItemsViewModel _model = new MyItemsViewModel();
protected override void Init()
{
DataTemplate MyItemsDataTemplate = new DataTemplate(() => new MyViewCell());
ListView listView = new ListView
{
ItemTemplate = MyItemsDataTemplate,
SeparatorVisibility = SeparatorVisibility.None,
HasUnevenRows = true,
IsPullToRefreshEnabled = false
};
listView.SetBinding(ListView.ItemsSourceProperty, new Binding(nameof(MyItemsViewModel.MyItems)));
Content = new StackLayout { Children = { new Label { Text = "If the text in the cells below is overlapping, this test has failed." }, listView } };
_model.MyItems.Add(new MyItem() { Description = "Record 1. OK" });
_model.MyItems.Add(new MyItem() { Description = "Record 2. Abcde ab ab abcdefg. x. Xxxxxx Z. Zzzzz" });
_model.MyItems.Add(new MyItem() { Description = "Record 3. This one gets partially stomped on." });
_model.MyItems.Add(new MyItem() { Description = "Record 4. OK" });
Content.BindingContext = _model;
}
[Preserve(AllMembers = true)]
class MyItem
{
public String Description { get; set; }
}
[Preserve(AllMembers = true)]
class MyItemsViewModel
{
public List<MyItem> MyItems { get; set; } = new List<MyItem>();
}
[Preserve(AllMembers = true)]
class MyViewCell : ViewCell
{
Label label;
public MyViewCell()
{
label = new Label
{
Margin = new Thickness(0, 3, 0, 3),
LineBreakMode = LineBreakMode.WordWrap,
HorizontalOptions = LayoutOptions.Start,
VerticalTextAlignment = TextAlignment.Start,
FontFamily = "HelveticaNeue-Light",
FontSize = 16
};
label.SetBinding(Label.TextProperty, new Binding(nameof(MyItem.Description)));
View = new StackLayout
{
Margin = new Thickness(15, 8, 10, 0),
Children = { label },
};
}
}
}
}