diff options
author | Rui Marinho <me@ruimarinho.net> | 2017-06-14 23:58:03 +0100 |
---|---|---|
committer | Jason Smith <jason.smith@xamarin.com> | 2017-06-14 15:58:03 -0700 |
commit | ec5492cd0da754bb372961a30170b7d3ce165ac2 (patch) | |
tree | 6c116878a05f92f806727e3b26d7b1aaaed13f31 /Xamarin.Forms.Controls.Issues | |
parent | 02c93b6b995d0bc775109466c4b9784c8d25171e (diff) | |
download | xamarin-forms-ec5492cd0da754bb372961a30170b7d3ce165ac2.tar.gz xamarin-forms-ec5492cd0da754bb372961a30170b7d3ce165ac2.tar.bz2 xamarin-forms-ec5492cd0da754bb372961a30170b7d3ce165ac2.zip |
[iOS,Android] Fix gap when setting Separator None and recycle element and on Android when using grouping (#949)
* [Controls] Add repo for bugzilla 39802
* [iOS] Make ContextCell hide the gap when we aren't using a separator
* [Controls] Update test
* [iOS] Only fix height if separator is hidden.
* [iOS] Only fix if it's a ListiView
* [Android] Fix separator showing when using Grouping
* Update Bugzilla39802.cs
Diffstat (limited to 'Xamarin.Forms.Controls.Issues')
2 files changed, 101 insertions, 0 deletions
diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla39802.cs b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla39802.cs new file mode 100644 index 00000000..cb926e67 --- /dev/null +++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla39802.cs @@ -0,0 +1,100 @@ +using Xamarin.Forms.CustomAttributes; +using Xamarin.Forms.Internals; +using System.Collections.ObjectModel; +using System.Collections.Generic; + +namespace Xamarin.Forms.Controls.Issues +{ + [Preserve(AllMembers = true)] + [Issue(IssueTracker.Bugzilla, 39802, "Gap between ListView cells even if SeparatorVisablity is set to none ", PlatformAffected.iOS)] + public class Bugzilla39802 : TestContentPage // or TestMasterDetailPage, etc ... + { + protected override void Init() + { + BackgroundColor = Color.Yellow; + + var list = new ObservableCollection<GroupedData>(); + + for (int i = 1; i <= 2; i++) + { + var group = new GroupedData { GroupName = $"Group #{i}" }; + + for (int j = 1; j < 30; j++) + { + var item = new MyItem { Title = $"Item: #{i}-{j}", Color = (j % 2 == 0) ? Color.Blue : Color.Red }; + + group.Add(item); + } + list.Add(group); + } + + ListItems = list; + + BindingContext = this; + var lst = new ListView(ListViewCachingStrategy.RecycleElement) + { + BackgroundColor = Color.Transparent, + ItemTemplate = new DataTemplate(typeof(ItemTemplate)), + GroupHeaderTemplate = new DataTemplate(typeof(GroupHeaderTemplate)), + IsGroupingEnabled = true, + GroupDisplayBinding = new Binding(nameof(GroupedData.GroupName)), + GroupShortNameBinding = new Binding(nameof(GroupedData.GroupName)), + }; + lst.SeparatorVisibility = SeparatorVisibility.None; + lst.SeparatorColor = Color.Green; + lst.SetBinding(ListView.ItemsSourceProperty, nameof(ListItems)); + Content = lst; + } + + public class ItemTemplate : ViewCell + { + public ItemTemplate() + { + var stk = new StackLayout + { + Padding = new Thickness(15, 0, 0, 0) + }; + stk.SetBinding(VisualElement.BackgroundColorProperty, nameof(MyItem.Color)); + var lbl = new Label + { + TextColor = Color.Yellow, + VerticalOptions = LayoutOptions.CenterAndExpand + }; + lbl.SetBinding(Label.TextProperty, nameof(MyItem.Title)); + stk.Children.Add(lbl); + View = stk; + } + } + public class GroupHeaderTemplate : ViewCell + { + public GroupHeaderTemplate() + { + var title = new Label { TextColor = Color.White, FontSize = 16 }; + title.SetBinding(Label.TextProperty, new Binding(nameof(GroupedData.GroupName), BindingMode.OneWay)); + + View = new StackLayout + { + Padding = new Thickness(8, 0), + VerticalOptions = LayoutOptions.StartAndExpand, + BackgroundColor = Color.Pink, + Orientation = StackOrientation.Horizontal, + Children = { title }, + }; + } + } + + public ObservableCollection<GroupedData> ListItems { get; set; } + public class MyItem + { + public string Title { get; set; } + + public Color Color { get; set; } + } + + [Preserve(AllMembers = true)] + public class GroupedData : List<MyItem> + { + public string GroupName { get; set; } + } + } +} diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems index 81e4bda0..97f26f7f 100644 --- a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems +++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems @@ -291,6 +291,7 @@ <Compile Include="$(MSBuildThisFileDirectory)ListViewNRE.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Bugzilla55745.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Bugzilla55365.cs" /> + <Compile Include="$(MSBuildThisFileDirectory)Bugzilla39802.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Bugzilla53179.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Bugzilla54036.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Bugzilla40161.cs" /> |