WPF DataGrid: Reordering Rows?
Asked Answered
A

3

16

I am creating a WPF data grid, and I want to be able to reorder rows by dragging and dropping, like this: I click on a row and drag it up or down. As I do, a marker shows where the row will be dropped if I release the mouse. When I do release the mouse, the dragged row is inserted where indicated by the marker.

Has anyone seen any articles or blog posts that show how to do this? I don't want to re-invent the wheel if I don't have to, and Google isn't turning up anything. Thanks.

Acrylyl answered 17/9, 2009 at 11:9 Comment(0)
A
11

Sorry--bad key word choice. Early morning, no coffee...

Turns out there are a number of samples, under "WPF DataGrid Drag and Drop". Here are three two:

Vincent Sibal's Blog
Philipp Sumi's Blog

Acrylyl answered 17/9, 2009 at 11:19 Comment(0)
T
5

I would suggest using the drag and drop behavior called GongSolutions.WPF.DragDrop. It works on any ItemsControl and thus also on DataGrid It allows MVVM style use cases using attached property setters to enable it. You should check out the link for a simple example.

Tildy answered 27/10, 2015 at 12:19 Comment(0)
G
0

I found this solution: Movable rows in WPF DataGrid best working for me. It's clean, MvvM pattern compatible. Has good example available to download.

Ganymede answered 12/2 at 7:9 Comment(1)
As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.Resnatron

© 2022 - 2024 — McMap. All rights reserved.