Feature/drag selection rectangle#344
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>
|
Hey @godlytalias, just checking in on this PR. It looks quite close to being ready, and I'd love to include it in the upcoming v1.5 preview release. Let me know if you're still planning to work on the remaining review items or if there's anything I can help with. Thanks! |
@w-ahmad I think the only pending item is to convert the internal fields as internal properties. I will update that. However I saw some discussions around this in #346, Whether some conclusion is made regarding it? |
|
@godlytalias, That discussion seems aimed at making the cells able to click thru so users can interact directly with the rows. IMO, let's stay focused on completing and merging this PR, and we can come to that feature later. |
Address PR review feedback: change the _dragRectangleCanvas and _isDragSelecting internal fields into internal properties (DragRectangleCanvas and IsDragSelecting) with private setters, following the codebase convention for internal members. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Resolve conflicts in src/TableView.cs (OnApplyTemplate: keep drag rectangle template-child wiring alongside upstream's null-conditional ScrollViewer.Loaded subscription) and src/TableView.Properties.cs (keep both ShowDragRectangle and ForceRowOrCellSelectionOnContextRequested properties). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Fixes CI build break: the internal fields _isDragSelecting and _dragRectangleCanvas were converted to internal properties (IsDragSelecting, DragRectangleCanvas), so update the test references accordingly. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Following the change of ShowDragRectangle's default value to true, update the default-value assertions accordingly. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
w-ahmad
left a comment
There was a problem hiding this comment.
Looks good to me!
thank for your valuable contribution @godlytalias.


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