This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
Hi, I have to implement Drag and Drop functionality for some of my Nodes in the Property Grid, but I can't find how to do that. I need to have a capability to rearrange sequence of Nodes in Property Grid. How can I do this? Thanks in advance. |
|
|
I'm afraid that's not a scenario we anticipated and I'm not sure how feasible it will be. There are two issues: first, detecting the actual drag and drop operation, and second, storing the new order of nodes in the grid. To detect the drag and drop I suspect you would need to re-template the grid, and implement appropriate mouse event handlers on the new property name template. (E.g. define a template consisting of a TextBlock with MouseDown and MouseUp event handlers. In the MouseDown event handler, capture the mouse; in the MouseUp event handler, test if this is the end of a drag [i.e. mouse captured], reorder the nodes if required, and release the capture. I'm omitting a LOT of details here as you can imagine!) I haven't actually prototyped this myself so you may need to do some experimenting to see what works. The ordering of nodes in the grid is determined by the order of the BindingView collection, as modified by any SortDescription on the default view. I can't think of a property path that you could give to a SortDescription that would enable the kind of sorting you require. So to store the new order you would probably have to remove the dragged PropertyGridRow from its old position and reinsert it at the new position. I know this all sounds a bit laborious, but as I said this isn't really a feature we expected to require. Do you have the option of providing a different UI for rearranging the nodes? For example if your users would accept "Move Up" and "Move Down" buttons instead of drag and drop then that would be a lot easier to implement as you would only need to reorder the nodes/PropertyGridRows, not worry about all the mouse stuff. (Note that this requires the SelectedGridItem property, which was introduced after the v1.0 release. If your copy of the grid doesn't have this property, update to the latest nightly to get it.) Hope this helps anyway... |
|