diff options
author | Paul DiPietro <pauldipietro@users.noreply.github.com> | 2016-07-18 22:05:08 -0500 |
---|---|---|
committer | Jason Smith <jason.smith@xamarin.com> | 2016-07-18 20:05:08 -0700 |
commit | a80d5c0de704837588138966be1b38a89ed24be9 (patch) | |
tree | 1cc8aba9aeb504f265ea6072e8e321eac10029d1 /Xamarin.Forms.Platform.WinRT/ListViewRenderer.cs | |
parent | 28d9e8aabc361efccc19d66d8361559d19f32698 (diff) | |
download | xamarin-forms-a80d5c0de704837588138966be1b38a89ed24be9.tar.gz xamarin-forms-a80d5c0de704837588138966be1b38a89ed24be9.tar.bz2 xamarin-forms-a80d5c0de704837588138966be1b38a89ed24be9.zip |
[8.1/UWP] ListView allows selection with enter key (#241)
Diffstat (limited to 'Xamarin.Forms.Platform.WinRT/ListViewRenderer.cs')
-rw-r--r-- | Xamarin.Forms.Platform.WinRT/ListViewRenderer.cs | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/Xamarin.Forms.Platform.WinRT/ListViewRenderer.cs b/Xamarin.Forms.Platform.WinRT/ListViewRenderer.cs index d6ec7038..5a93eb10 100644 --- a/Xamarin.Forms.Platform.WinRT/ListViewRenderer.cs +++ b/Xamarin.Forms.Platform.WinRT/ListViewRenderer.cs @@ -4,6 +4,7 @@ using System.ComponentModel; using System.Linq; using System.Threading.Tasks; using Windows.Foundation; +using Windows.System; using Windows.UI.Xaml; using Windows.UI.Xaml.Controls; using Windows.UI.Xaml.Data; @@ -76,6 +77,9 @@ 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; + if (ShouldCustomHighlight) { List.SelectionChanged += OnControlSelectionChanged; @@ -140,6 +144,7 @@ namespace Xamarin.Forms.Platform.WinRT if (List != null) { List.Tapped -= ListOnTapped; + List.KeyUp -= OnKeyPressed; if (ShouldCustomHighlight) { @@ -521,6 +526,12 @@ namespace Xamarin.Forms.Platform.WinRT #endif } + void OnKeyPressed(object sender, KeyRoutedEventArgs e) + { + if (e.Key == VirtualKey.Enter) + OnListItemClicked(List.SelectedIndex); + } + void OnControlSelectionChanged(object sender, SelectionChangedEventArgs e) { RestorePreviousSelectedVisual(); |