diff options
Diffstat (limited to 'Xamarin.Forms.Platform.WinRT/ListViewRenderer.cs')
-rw-r--r-- | Xamarin.Forms.Platform.WinRT/ListViewRenderer.cs | 35 |
1 files changed, 13 insertions, 22 deletions
diff --git a/Xamarin.Forms.Platform.WinRT/ListViewRenderer.cs b/Xamarin.Forms.Platform.WinRT/ListViewRenderer.cs index 5a93eb10..2cd8562c 100644 --- a/Xamarin.Forms.Platform.WinRT/ListViewRenderer.cs +++ b/Xamarin.Forms.Platform.WinRT/ListViewRenderer.cs @@ -79,11 +79,8 @@ namespace Xamarin.Forms.Platform.WinRT // We also want to watch for the Enter key being pressed for selection List.KeyUp += OnKeyPressed; - - if (ShouldCustomHighlight) - { - List.SelectionChanged += OnControlSelectionChanged; - } + + List.SelectionChanged += OnControlSelectionChanged; List.SetBinding(ItemsControl.ItemsSourceProperty, ""); } @@ -146,10 +143,7 @@ namespace Xamarin.Forms.Platform.WinRT List.Tapped -= ListOnTapped; List.KeyUp -= OnKeyPressed; - if (ShouldCustomHighlight) - { - List.SelectionChanged -= OnControlSelectionChanged; - } + List.SelectionChanged -= OnControlSelectionChanged; List.DataContext = null; List = null; @@ -204,18 +198,6 @@ namespace Xamarin.Forms.Platform.WinRT ContentControl _headerControl; readonly List<BrushedElement> _highlightedElements = new List<BrushedElement>(); - bool ShouldCustomHighlight - { - get - { -#if WINDOWS_UWP - return false; -#else - return Device.Idiom == TargetIdiom.Phone; -#endif - } - } - void ClearSizeEstimate() { Element.ClearValue(CellControl.MeasuredEstimateProperty); @@ -543,7 +525,8 @@ namespace Xamarin.Forms.Platform.WinRT if (cell == null) return; - if (ShouldCustomHighlight) +#if !WINDOWS_UWP + if (Device.Idiom == TargetIdiom.Phone) { FrameworkElement element = FindElement(cell); if (element != null) @@ -551,6 +534,14 @@ namespace Xamarin.Forms.Platform.WinRT SetSelectedVisual(element); } } +#endif + + // This is used for respecting ListView selection changes via keyboard, as the SelectedItem + // value is otherwise not set. + if (Element.SelectedItem != List.SelectedItem) + { + ((IElementController)Element).SetValueFromRenderer(ListView.SelectedItemProperty, List.SelectedItem); + } } FrameworkElement FindElement(object cell) |