void onListKeyUp(KeyEventArgs args) { if (KeyboardHelper.IsKeyPressed(ModifierKeys.Control) && args.Key == Key.A) { if (Selection.Items.Count() == Items.Count()) { SelectedItemIDs.Clear(); } else { SelectedItemIDs.AddRange(Items.Select(Items => Items.Item.ItemId)); } } }
void onItemClicked(ItemClickedEventArgs args) { var curItem = args.Item; var prevItem = previouslyClickedItem; var isStrgPressed = KeyboardHelper.IsKeyPressed(ModifierKeys.Control); var isShiftPressed = KeyboardHelper.IsKeyPressed(ModifierKeys.Shift); var isAltPressed = KeyboardHelper.IsKeyPressed(ModifierKeys.Alt); if (isAltPressed) { return; } if (isStrgPressed) { if (curItem.IsSelected) { SelectedItemIDs.Remove(curItem.Item.ItemId); } else { SelectedItemIDs.Add(curItem.Item.ItemId); } } else if (isShiftPressed) { var section = this.Items.Subsection(curItem, prevItem); if (section.All(item => item.IsSelected)) { SelectedItemIDs.RemoveMany(section.Select(item => item.Item.ItemId)); } else { SelectedItemIDs.AddRange(section.Select(item => item.Item.ItemId).Except(this.SelectedItemIDs.Items)); } } else { if (SelectedItemIDs.Count == 1 && SelectedItemIDs.Items.Contains(curItem.Item.ItemId)) { return; } this.SelectedItemIDs.Clear(); SelectedItemIDs.Add(curItem.Item.ItemId); } previouslyClickedItem = curItem; }