Conversation
Signed-off-by: Godly Alias <godlyalias@microsoft.com>
Signed-off-by: Godly Alias <godlyalias@microsoft.com>
Signed-off-by: Godly Alias <godlyalias@microsoft.com>
Signed-off-by: Godly Alias <godlyalias@microsoft.com>
Signed-off-by: Godly Alias <godlyalias@microsoft.com>
|
Thanks for the PR @godlytalias, it looks great. Quick question: can we enable auto-scroll even when |
@w-ahmad Sounds good, I guess we should then expose a property for devs to toggle it and have to keep it disabled by default for not breaking current behavior? We can enable the behavior only when DragSelectionRectangle being enabled? Or do you have different opinion? |
I think the auto-scroll must be there even when the DragSelectionRectangle is not visible and there is no need to add property to turn it on or off. This is because most DataGrid controls (tried on WPF and Synfusion) and even Excel offers it by default. The DragSelectionRectangle is a new feature for TableView, for which you’ve already added a flag property to turn it on or off. |
Okay sure, I will keep the autoscroll turned on by default then. Thanks |
Signed-off-by: Godly Alias <godlyalias@microsoft.com>
| /// <summary> | ||
| /// Identifies the <see cref="ShowDragRectangle"/> dependency property. | ||
| /// </summary> | ||
| public static readonly DependencyProperty ShowDragRectangleProperty = DependencyProperty.Register(nameof(ShowDragRectangle), typeof(bool), typeof(TableView), new PropertyMetadata(false, OnShowDragRectangleChanged)); |
There was a problem hiding this comment.
Let's set the default value to true.
| _dragRectangle.Width = 0; | ||
| _dragRectangle.Height = 0; | ||
|
|
||
| _dragRectangle.Visibility = Visibility.Visible; |
There was a problem hiding this comment.
I suggest setting the visibility on the drag canvas itself to reduce the number of elements loading at the start and if ShowDragRectangle is set to false, the canvas won’t load at all.
There was a problem hiding this comment.
Actually even if we keep visibility as 'collapsed', the element would still be loaded just that it won't participate in rendering, https://learn.microsoft.com/en-us/uwp/api/windows.ui.xaml.uielement.visibility?view=winrt-28000#remarks
If the concern is about reducing elements, we may have to add logic for x:load here
There was a problem hiding this comment.
That's interesting. I'll leave it up to you—if there's no need to set the visibility on the canvas itself, then keep it as is. If you think x:Load could make a difference, go ahead and use it.
| private bool _ensureColumns = true; | ||
| private readonly List<TableViewRow> _rows = []; | ||
| private readonly CollectionView _collectionView = []; | ||
| internal Canvas? _dragRectangleCanvas; |
There was a problem hiding this comment.
Making a field internal feels a bit unusual.
There was a problem hiding this comment.
Kept it internal as these fields are to be accessed by TableViewCell class as well but not to be exposed outside the assembly. Whether you think differently?
There was a problem hiding this comment.
Got it, let’s turn them into internal properties then.
| internal Canvas? _dragRectangleCanvas; | ||
| private Border? _dragRectangle; | ||
| private Point? _dragStartPoint; | ||
| internal bool _isDragSelecting; |
There was a problem hiding this comment.
Making a field internal feels a bit unusual.


Add Drag Selection Rectangle ( #334 )
Adds a semi-transparent rectangle overlay during cell/row drag selection, providing visual feedback similar to File Explorer's drag-select experience.
DragSelection.mp4
Feature Overview
DispatcherTimer(16ms/~60fps) withScrollViewer.ChangeView; horizontal scroll uses the existingHorizontalOffsetDP pattern.ScrollViewer.ViewChangedhandler with hit-test at the clamped pointer position.ShowDragRectangleproperty — Newbooldependency property (default:true) to enable/disable the rectangle. Setting tofalsemid-drag correctly tears down the rectangle. The underlying drag selection behavior (cell/row selection via pointer movement) is unaffected by this property.Files Changed
src/TableView.Properties.csShowDragRectangleDP + property changed callbacksrc/TableView.csStartDragRectangle,UpdateDragRectangleVisual,PositionDragRectangle, auto-scroll timer,ViewChangedhandler,FindCellAtCanvasPoint,EndDragRectanglecleanup,OnCurrentCellChangeddrag optimization,OnCellSelectionChangedcoalescing,OnUnloadedcleanupsrc/TableViewCell.csOnPointerPressedstarts drag,OnPointerReleasedends drag,OnPointerCaptureLostsafety net,OnManipulationDeltaupdates rectangle visual,TransformPointToCanvashelper,ApplyCurrentCellState(skipFocus)src/Themes/Resources.xamlsrc/Themes/TableView.xamlCanvas+Borderoverlay in control template (Grid.Row="1",IsHitTestVisible="False")samples/.../SelectionPage.xamlShowDragRectangleToggleSwitch + code substitutiontests/DragSelectionRectangleTests.csLifecycle