summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Platform.WinRT
diff options
context:
space:
mode:
authorPaul DiPietro <pauldipietro@users.noreply.github.com>2016-07-19 03:05:08 (GMT)
committerJason Smith <jason.smith@xamarin.com>2016-07-19 03:05:08 (GMT)
commita80d5c0de704837588138966be1b38a89ed24be9 (patch)
tree1cc8aba9aeb504f265ea6072e8e321eac10029d1 /Xamarin.Forms.Platform.WinRT
parent28d9e8aabc361efccc19d66d8361559d19f32698 (diff)
downloadxamarin-forms-a80d5c0de704837588138966be1b38a89ed24be9.zip
xamarin-forms-a80d5c0de704837588138966be1b38a89ed24be9.tar.gz
xamarin-forms-a80d5c0de704837588138966be1b38a89ed24be9.tar.bz2
[8.1/UWP] ListView allows selection with enter key (#241)
Diffstat (limited to 'Xamarin.Forms.Platform.WinRT')
-rw-r--r--Xamarin.Forms.Platform.WinRT/ListViewRenderer.cs11
1 files changed, 11 insertions, 0 deletions
diff --git a/Xamarin.Forms.Platform.WinRT/ListViewRenderer.cs b/Xamarin.Forms.Platform.WinRT/ListViewRenderer.cs
index d6ec703..5a93eb1 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();