[UWP] Roll back PR 3400 so the correct context is passed into Tapped (#5476)
authorShane Neuville <shane94@hotmail.com>
Thu, 7 Mar 2019 17:17:43 +0000 (10:17 -0700)
committerSamantha Houts <samhouts@users.noreply.github.com>
Thu, 7 Mar 2019 17:17:43 +0000 (09:17 -0800)
* [UWP] pass the correct object to ItemView

* - remove object from source

Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue935.cs
Xamarin.Forms.Platform.UAP/ListViewRenderer.cs

index 56298c4..2075d61 100644 (file)
@@ -24,7 +24,6 @@ namespace Xamarin.Forms.Controls.Issues
        [Preserve(AllMembers = true)]
        public class CustomViewCell : ViewCell 
        {
-
                public CustomViewCell ()
                {
                        int tapsFired = 0;
@@ -35,14 +34,29 @@ namespace Xamarin.Forms.Controls.Issues
                                Text = "I have been selected:"
                        };
 
+                       if (this is CustomViewCellBindingContext)
+                               label.Text = "If you can read this text the UI Test has failed";
+
                        Tapped += (s, e) => {
                                tapsFired++;
                                label.Text = "I have been selected:" + tapsFired;
+
+                               var cell = (CustomViewCell)s;
                        };
 
                        View = label;
                }
        }
+
+
+       [Preserve(AllMembers = true)]
+       public class CustomViewCellBindingContext : CustomViewCell
+       {
+               public CustomViewCellBindingContext()
+               {
+               }
+       }
+
 #if UITEST
        [NUnit.Framework.Category(Core.UITests.UITestCategories.UwpIgnore)]
 #endif
@@ -55,7 +69,7 @@ namespace Xamarin.Forms.Controls.Issues
                        Title = "List Page";
 
                        var items = new [] {
-                               new CustomViewCell (),
+                               new CustomViewCellBindingContext()
                        };
                                
                        var cellTemplate = new DataTemplate (typeof(CustomViewCell));
index 4281041..0387d47 100644 (file)
@@ -722,9 +722,9 @@ namespace Xamarin.Forms.Platform.UWP
                        List.SelectedIndex = index;
                }
 
-               void OnListItemClicked(int index, Cell cell = null)
+               void OnListItemClicked(int index)
                {
-                       Element.NotifyRowTapped(index, cell);
+                       Element.NotifyRowTapped(index);
                        _itemWasClicked = true;
                }
 
@@ -735,7 +735,7 @@ namespace Xamarin.Forms.Platform.UWP
                                var templatedItems = TemplatedItemsView.TemplatedItems;
                                var selectedItemIndex = templatedItems.GetGlobalIndexOfItem(e.ClickedItem);
 
-                               OnListItemClicked(selectedItemIndex, e.ClickedItem as Cell);
+                               OnListItemClicked(selectedItemIndex);
                        }
                }