private void RectangleSelection_PointerPressed(object sender, PointerRoutedEventArgs e) { itemsPosition.Clear(); originDragPoint = new Point(e.GetCurrentPoint(uiElement).Position.X, e.GetCurrentPoint(uiElement).Position.Y); // Initial drag point relative to the topleft corner prevSelectedItems = uiElement.SelectedItems.Cast <object>().ToList(); // Save current selected items var verticalOffset = scrollViewer?.VerticalOffset ?? 0; originDragPoint.Y += verticalOffset; // Initial drag point relative to the top of the list (considering scrolled offset) if (!e.GetCurrentPoint(uiElement).Properties.IsLeftButtonPressed || e.Pointer.PointerDeviceType == Windows.Devices.Input.PointerDeviceType.Touch) { // Trigger only on left click, do not trigger with touch return; } selectionStrategy = e.KeyModifiers.HasFlag(VirtualKeyModifiers.Control) ? new InvertPreviousItemSelectionStrategy(uiElement.SelectedItems, prevSelectedItems) : e.KeyModifiers.HasFlag(VirtualKeyModifiers.Shift) ? (ItemSelectionStrategy) new ExtendPreviousItemSelectionStrategy(uiElement.SelectedItems, prevSelectedItems) : new IgnorePreviousItemSelectionStrategy(uiElement.SelectedItems); selectionStrategy.HandleNoItemSelected(); uiElement.PointerMoved -= RectangleSelection_PointerMoved; uiElement.PointerMoved += RectangleSelection_PointerMoved; if (selectionChanged != null) { // Unsunscribe from SelectionChanged event for performance uiElement.SelectionChanged -= selectionChanged; } uiElement.CapturePointer(e.Pointer); selectionState = SelectionState.Starting; }
private void View_RectangleDrawStart(object sender, Windows.UI.Xaml.Input.PointerRoutedEventArgs e) { Point CurrentPoint = e.GetCurrentPoint(View).Position; AbsStartPoint = new Point(CurrentPoint.X + InnerScrollView.HorizontalOffset, CurrentPoint.Y + InnerScrollView.VerticalOffset); View.SelectedItems.Clear(); View.CapturePointer(e.Pointer); View.PointerMoved += View_PointerMoved; }
private void View_RectangleDrawStart(object sender, PointerRoutedEventArgs e) { PointerPoint Pointer = e.GetCurrentPoint(View); if (e.Pointer.PointerDeviceType == PointerDeviceType.Mouse && Pointer.Properties.IsLeftButtonPressed) { Point CurrentPoint = Pointer.Position; AbsStartPoint = new Point(CurrentPoint.X + (InnerScrollView?.HorizontalOffset).GetValueOrDefault(), CurrentPoint.Y + (InnerScrollView?.VerticalOffset).GetValueOrDefault()); if (IsEnabled) { View.CapturePointer(e.Pointer); } } }
private void RectangleSelection_PointerPressed(object sender, PointerRoutedEventArgs e) { itemsPosition.Clear(); originDragPoint = new Point(e.GetCurrentPoint(uiElement).Position.X, e.GetCurrentPoint(uiElement).Position.Y); // Initial drag point relative to the topleft corner var verticalOffset = scrollViewer?.VerticalOffset ?? 0; originDragPoint.Y = originDragPoint.Y + verticalOffset; // Initial drag point relative to the top of the list (considering scrolled offset) if (!e.GetCurrentPoint(uiElement).Properties.IsLeftButtonPressed) { // Trigger only on left click return; } uiElement.PointerMoved -= RectangleSelection_PointerMoved; uiElement.PointerMoved += RectangleSelection_PointerMoved; if (selectionChanged != null) { // Unsunscribe from SelectionChanged event for performance uiElement.SelectionChanged -= selectionChanged; } uiElement.CapturePointer(e.Pointer); selectionState = SelectionState.Starting; }