Check for ValueType items to perform equals (#8299)
authorGlenn Versweyveld <Depechie@users.noreply.github.com>
Thu, 31 Oct 2019 10:37:35 +0000 (11:37 +0100)
committerGerald Versluis <gerald.versluis@microsoft.com>
Thu, 31 Oct 2019 10:37:35 +0000 (11:37 +0100)
Xamarin.Forms.Platform.UAP/ListViewRenderer.cs

index ce98c7f..3620449 100644 (file)
@@ -774,7 +774,14 @@ namespace Xamarin.Forms.Platform.UWP
 
                void OnControlSelectionChanged(object sender, WSelectionChangedEventArgs e)
                {
-                       if (Element.SelectedItem != List.SelectedItem)
+                       bool areEqual = false;
+
+                       if (Element.SelectedItem != null && Element.SelectedItem.GetType().IsValueType)
+                               areEqual = Element.SelectedItem.Equals(List.SelectedItem);
+                       else
+                               areEqual = Element.SelectedItem == List.SelectedItem;
+
+                       if (!areEqual)
                        {
                                if (_itemWasClicked)
                                        List.SelectedItem = Element.SelectedItem;