private void TimeLine_PreviewMouseDown(object sender, MouseButtonEventArgs e) { FrameworkElement element = null; try { element = ((FrameworkElement)e.OriginalSource).TemplatedParent as FrameworkElement; } catch (InvalidCastException) { return; } AllItems.ForEach(i => i.IsSelected = false); SelectedItem = null; if (element is TrackItem trackItem) { trackItem.IsSelected = true; SelectedItem = trackItem; ItemSelected?.Invoke(trackItem, new EventArgs()); } else { ItemDeselected?.Invoke(null, new EventArgs()); } }
protected virtual void OnDeselected() { if (ExpandOnSelect) { Collapse(); } ItemDeselected?.Invoke(this); }
private void UserControl_Tapped(object sender, TappedRoutedEventArgs e) { if (IsSelected && ItemDeselected != null) { ItemDeselected?.Invoke(sender, null); } if (!IsSelected && ItemSelected != null) { ItemSelected?.Invoke(sender, null); } IsSelected = !IsSelected; }
private void ToggleItemIsSelected(SelectedAndTextAndTag clickedItem) { // toggle selection if (clickedItem == null) { return; } if (!clickedItem.IsSelected) { clickedItem.IsSelected = true; ItemSelected?.Invoke(this, clickedItem.TextAndTag); } else if (IsMultiSelectCheckBoxEnabled) { clickedItem.IsSelected = false; ItemDeselected?.Invoke(this, clickedItem.TextAndTag); } }