diff options
author | Samantha Houts <samantha@teamredwall.com> | 2017-01-31 11:49:15 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-01-31 11:49:15 -0800 |
commit | ae59382c9046501edb37882ad1c065aacce60319 (patch) | |
tree | 3578ce8e0396a38aeb8323d4051f50a19a5340fb /Xamarin.Forms.Platform.WinRT/ListViewRenderer.cs | |
parent | 23d228039acc504049f6a5153f5839d4c714930a (diff) | |
download | xamarin-forms-ae59382c9046501edb37882ad1c065aacce60319.tar.gz xamarin-forms-ae59382c9046501edb37882ad1c065aacce60319.tar.bz2 xamarin-forms-ae59382c9046501edb37882ad1c065aacce60319.zip |
[All] Basic Accessibility Support (#713)
* [Core] Add accessibility properties
* [Controls] Add accessibility gallery
* [iOS] Implement accessibility properties
* [Android] Implement accessibilty properties
* [Win] Implement accessibility properties
* [Win] Select ListView item on selected for a11y
* Update docs
* TODO: macOS accessibility
* [iOS] Fix failing UI Tests
Diffstat (limited to 'Xamarin.Forms.Platform.WinRT/ListViewRenderer.cs')
-rw-r--r-- | Xamarin.Forms.Platform.WinRT/ListViewRenderer.cs | 28 |
1 files changed, 13 insertions, 15 deletions
diff --git a/Xamarin.Forms.Platform.WinRT/ListViewRenderer.cs b/Xamarin.Forms.Platform.WinRT/ListViewRenderer.cs index db581d52..031e2cf3 100644 --- a/Xamarin.Forms.Platform.WinRT/ListViewRenderer.cs +++ b/Xamarin.Forms.Platform.WinRT/ListViewRenderer.cs @@ -77,9 +77,6 @@ namespace Xamarin.Forms.Platform.WinRT // and prevented from bubbling up) rather than ListView.ItemClick List.Tapped += ListOnTapped; - // We also want to watch for the Enter key being pressed for selection - List.KeyUp += OnKeyPressed; - List.SelectionChanged += OnControlSelectionChanged; List.SetBinding(ItemsControl.ItemsSourceProperty, ""); @@ -141,7 +138,6 @@ namespace Xamarin.Forms.Platform.WinRT if (List != null) { List.Tapped -= ListOnTapped; - List.KeyUp -= OnKeyPressed; List.SelectionChanged -= OnControlSelectionChanged; @@ -508,17 +504,6 @@ namespace Xamarin.Forms.Platform.WinRT #endif } - void OnKeyPressed(object sender, KeyRoutedEventArgs e) - { - if (e.Key == VirtualKey.Enter) - { - if (Element.SelectedItem != null && Element.SelectedItem != List.SelectedItem) - { - ((IElementController)Element).SetValueFromRenderer(ListView.SelectedItemProperty, List.SelectedItem); - } - } - } - void OnControlSelectionChanged(object sender, SelectionChangedEventArgs e) { RestorePreviousSelectedVisual(); @@ -540,6 +525,10 @@ namespace Xamarin.Forms.Platform.WinRT } } #endif + + // A11y: Tapped event will not be routed when Narrator is active + // Also handles keyboard selection + SelectElementItem(); } FrameworkElement FindElement(object cell) @@ -553,6 +542,15 @@ namespace Xamarin.Forms.Platform.WinRT return null; } + void SelectElementItem() + { + if (List.SelectedItem != null && Element.SelectedItem != List.SelectedItem) + { + ((IElementController)Element).SetValueFromRenderer(ListView.SelectedItemProperty, List?.SelectedItem); + OnElementItemSelected(null, new SelectedItemChangedEventArgs(Element?.SelectedItem)); + } + } + #if WINDOWS_UWP void RestorePreviousSelectedVisual() { |