Skip to content

Commit 0db7a08

Browse files
Added support for ctrl + click deselection in grid view. (#788)
1 parent 46cafa8 commit 0db7a08

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

Files/UserControls/LayoutModes/PhotoAlbum.xaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,7 @@
333333
DataContext="{x:Bind}"
334334
DataContextChanged="FileListGridItem_DataContextChanged"
335335
EffectiveViewportChanged="Grid_EffectiveViewportChanged"
336+
PointerPressed="FileListGridItem_PointerPressed"
336337
IsRightTapEnabled="True"
337338
RightTapped="StackPanel_RightTapped"
338339
Tag="ItemRoot"

Files/UserControls/LayoutModes/PhotoAlbum.xaml.cs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System;
33
using System.Collections.Generic;
44
using System.Linq;
5+
using Windows.Devices.Input;
56
using Windows.System;
67
using Windows.UI.Core;
78
using Windows.UI.Xaml;
@@ -211,5 +212,27 @@ private void FileListGridItem_DataContextChanged(object sender, DataContextChang
211212
{
212213
InitializeDrag(sender as UIElement);
213214
}
215+
216+
private void FileListGridItem_PointerPressed(object sender, PointerRoutedEventArgs e)
217+
{
218+
if (e.KeyModifiers == VirtualKeyModifiers.Control)
219+
{
220+
var listedItem = (sender as Grid).DataContext as ListedItem;
221+
if (FileList.SelectedItems.Contains(listedItem))
222+
{
223+
FileList.SelectedItems.Remove(listedItem);
224+
// Prevent issues arising caused by the default handlers attempting to select the item that has just been deselected by ctrl + click
225+
e.Handled = true;
226+
}
227+
}
228+
else if (e.GetCurrentPoint(sender as UIElement).Properties.IsLeftButtonPressed)
229+
{
230+
var listedItem = (sender as Grid).DataContext as ListedItem;
231+
232+
FileList.SelectedItems.Clear(); // Control not clicked, clear selected items
233+
FileList.SelectedItems.Add(listedItem);
234+
FileList.SelectedItem = listedItem;
235+
}
236+
}
214237
}
215238
}

0 commit comments

Comments
 (0)