private void TokenizingTextBoxItem_Click(object sender, RoutedEventArgs e) { if (sender is TokenizingTextBoxItem item) { bool isControlDown = CoreWindow.GetForCurrentThread().GetKeyState(VirtualKey.Control).HasFlag(CoreVirtualKeyStates.Down); if (!item.IsSelected && !isControlDown) { foreach (var child in _wrapPanel.Children) { if (child is TokenizingTextBoxItem childItem) { childItem.IsSelected = false; } } SelectedItemsInternal.Clear(); } item.IsSelected = !item.IsSelected; if (item.IsSelected) { SelectedItemsInternal.Add(item); } else { SelectedItemsInternal.Remove(item); } TokenItemClicked?.Invoke(this, item); // TODO: Do we want to use EventArgs here to have the OriginalSource like ItemClickEventArgs? } }
private void SelectAll() { foreach (var child in _wrapPanel.Children) { if (child is TokenizingTextBoxItem item) { item.IsSelected = true; SelectedItemsInternal.Add(item); } } }