Disable packager for CollectionView on UWP (#8404)
authorE.Z. Hart <hartez@users.noreply.github.com>
Mon, 18 Nov 2019 09:19:50 +0000 (02:19 -0700)
committerGerald Versluis <gerald.versluis@microsoft.com>
Mon, 18 Nov 2019 09:19:50 +0000 (10:19 +0100)
* Reproduce issue 8366

* Clean up old comments

* Turn off packaging for the CollectionView on UWP
Fixes #8366

Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue8366.cs [new file with mode: 0644]
Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems
Xamarin.Forms.Core/Items/ItemsView.cs
Xamarin.Forms.Platform.UAP/CollectionView/ItemsViewRenderer.cs

diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue8366.cs b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue8366.cs
new file mode 100644 (file)
index 0000000..4705f36
--- /dev/null
@@ -0,0 +1,96 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using Xamarin.Forms.CustomAttributes;
+using Xamarin.Forms.Internals;
+
+#if UITEST
+using Xamarin.Forms.Core.UITests;
+using Xamarin.UITest;
+using NUnit.Framework;
+#endif
+
+namespace Xamarin.Forms.Controls.Issues
+{
+       [Preserve(AllMembers = true)]
+       [Issue(IssueTracker.Bugzilla, 8366, "[Bug] UWP CollectionView Floating Row and Toolbar clipped")]
+       public class Issue8366 : TestMasterDetailPage
+       {
+               NavigationPage _items;
+               NavigationPage _other;
+
+               protected override void Init()
+               {
+                       MasterBehavior = MasterBehavior.Split;
+
+                       _items = new NavigationPage(Items());
+                       _other = new NavigationPage(Other());
+
+                       Detail = _items;
+                       Master = MasterPage();
+               }
+
+               ContentPage MasterPage() 
+               {
+                       var page = new ContentPage();
+
+                       var menu = new StackLayout();
+
+                       var instructions = new Label { Margin = 3, Text = "Tap 'Other' to change the Detail page. " +
+                               "Then tap 'Items' to return to this page. " +
+                               "If the CollectionView does not show a garbled mess at the top, this test has passed." };
+
+                       menu.Children.Add(instructions);
+
+                       var buttonItems = new Button { Text = "Items" };
+                       var buttonOther = new Button { Text = "Other" };
+
+                       page.Content = menu;
+
+                       buttonItems.Clicked += (sender, args) => { Detail = _items; };
+                       buttonOther.Clicked += (sender, args) => { Detail = _other; };
+
+                       menu.Children.Add(buttonItems);
+                       menu.Children.Add(buttonOther);
+
+                       page.Title = "8366 Master";
+
+                       return page;
+               }
+
+               ContentPage Items()
+               {
+                       var page = new ContentPage
+                       {
+                               Title = "Items"
+                       };
+
+                       var cv = new CollectionView();
+
+                       var items = new List<string>() { "uno", "dos", "tres" };
+
+                       cv.ItemsSource = items;
+
+                       cv.ItemTemplate = new DataTemplate(() => {
+                               var root = new Label();
+                               root.SetBinding(Label.TextProperty, new Binding("."));
+                               return root;
+                       });
+
+                       page.Content = cv;
+
+                       return page;
+               }
+
+               ContentPage Other()
+               {
+                       var page = new ContentPage
+                       {
+                               Title = "Other",
+                               Content = new Label { Text = "Other page" }
+                       };
+
+                       return page;
+               }
+       }
+}
index cb39b75..106f561 100644 (file)
     </Compile>
     <Compile Include="$(MSBuildThisFileDirectory)Issue8222.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)Issue8167.cs" />
+    <Compile Include="$(MSBuildThisFileDirectory)Issue8366.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)Issue8269.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)RefreshViewTests.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)Issue7338.cs" />
index 05c1a43..37f25ff 100644 (file)
@@ -125,10 +125,6 @@ namespace Xamarin.Forms
                        BindableProperty.Create(nameof(ItemsLayout), typeof(IItemsLayout), typeof(ItemsView),
                                LinearItemsLayout.Vertical);
 
-
-               //      public abstract IItemsLayout ItemsLayout { get; }
-
-
                protected IItemsLayout InternalItemsLayout
                {
                        get => (IItemsLayout)GetValue(InternalItemsLayoutProperty);
@@ -144,7 +140,6 @@ namespace Xamarin.Forms
                        set => SetValue(ItemSizingStrategyProperty, value);
                }
 
-
                public static readonly BindableProperty ItemTemplateProperty =
                        BindableProperty.Create(nameof(ItemTemplate), typeof(DataTemplate), typeof(ItemsView));
 
index e767066..c411b20 100644 (file)
@@ -26,6 +26,11 @@ namespace Xamarin.Forms.Platform.UWP
                FrameworkElement _emptyView;
                View _formsEmptyView;
 
+               protected ItemsViewRenderer()
+               {
+                       AutoPackage = false;
+               }
+
                protected TItemsView ItemsView => Element;
                protected ItemsControl ItemsControl { get; private set; }