From 97bc024a0ede694d867e65568aa045acfa6b99b3 Mon Sep 17 00:00:00 2001 From: Paul DiPietro Date: Fri, 30 Sep 2016 14:28:08 -0500 Subject: [WinRT] Fix regression on ListView selection with enter key (#402) --- Xamarin.Forms.Platform.WinRT/ListViewRenderer.cs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/Xamarin.Forms.Platform.WinRT/ListViewRenderer.cs b/Xamarin.Forms.Platform.WinRT/ListViewRenderer.cs index d65f7f6f..db581d52 100644 --- a/Xamarin.Forms.Platform.WinRT/ListViewRenderer.cs +++ b/Xamarin.Forms.Platform.WinRT/ListViewRenderer.cs @@ -511,7 +511,12 @@ namespace Xamarin.Forms.Platform.WinRT void OnKeyPressed(object sender, KeyRoutedEventArgs e) { if (e.Key == VirtualKey.Enter) - OnListItemClicked(List.SelectedIndex); + { + if (Element.SelectedItem != null && Element.SelectedItem != List.SelectedItem) + { + ((IElementController)Element).SetValueFromRenderer(ListView.SelectedItemProperty, List.SelectedItem); + } + } } void OnControlSelectionChanged(object sender, SelectionChangedEventArgs e) @@ -535,13 +540,6 @@ namespace Xamarin.Forms.Platform.WinRT } } #endif - - // This is used for respecting ListView selection changes via keyboard, as the SelectedItem - // value is otherwise not set. - if (Element.SelectedItem != null && Element.SelectedItem != List.SelectedItem) - { - ((IElementController)Element).SetValueFromRenderer(ListView.SelectedItemProperty, List.SelectedItem); - } } FrameworkElement FindElement(object cell) -- cgit v1.2.3