none
GridView with custom ItemsPanel - reorder does not work

    Question

  • I have simple GridView with reorder functionality but I have to use custom ItemsPanel(WrapGrid nor VariableSizedWrapGrid don't satisfy my requirements). With default implementations of Panel(like WrapGrid or StackPanel) reordering works(but with StackPane some fancy UI animations are missing). I haven't found anything special in StackPanel/WrapGrid implementation that makes reordering working. One workaround to this problem is to derive from StackPanel(because WrapGrid is sealed and (Oriented)VirtualizingStackPanel's is inaccessible).

    Code demonstrating(page + custom panel) this problem is available here(online and zipped): http://sdrv.ms/ShQdyE

    Tuesday, August 14, 2012 1:47 PM

Answers

  • Hi Fiolek,
        I've been playing with your code.  It does seem that you need to do your own drag and drop plumbing for this custom panel - you need to detect when the item(s) are being dragged, and then determine where to drop them.  You can listen to the DragItemsStarting event to determine what's being dragged, and then to the Drop event for when the items are being dropped.  The only thing I haven't figured out yet is where exactly to drop them, but I don't think it's that difficult.

    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    Monday, August 20, 2012 3:11 PM

All replies

  • I'm confused - is this a problem that you have or are you proposing a solution to a problem you ran into for other's benefit?

    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    Tuesday, August 14, 2012 7:47 PM
  • Maybe I didn't make things clear(and I apologize for that), but I do have a problem(not working reordering in GridView with custom ItemsPanel) for which I found the workaround that is just a workaround(only partly solves the problem).

    So the question is - what should I do to use reordering functionality of GridView that uses custom implementation of ItemsPanel?

    Tuesday, August 14, 2012 11:14 PM
  • Hi Fiolek,
        I've been playing with your code.  It does seem that you need to do your own drag and drop plumbing for this custom panel - you need to detect when the item(s) are being dragged, and then determine where to drop them.  You can listen to the DragItemsStarting event to determine what's being dragged, and then to the Drop event for when the items are being dropped.  The only thing I haven't figured out yet is where exactly to drop them, but I don't think it's that difficult.

    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    Monday, August 20, 2012 3:11 PM
  • Thank you for your answer. It is sad that there is no easier way(or just non-sealed WrapGrid or something like it).
    Monday, August 20, 2012 5:08 PM
  • Hi-  Reviving this thread as I have a similar problem.   We have a custom panel for a GridView that uses a Canvas to arrange its elements.  We needed this to completely control the size of the items.    I'd really like to get drag and drop working for that.

    I notice by setting CanReorderItems="True", AllowDrop="True", and  CanDragItems="True" on the GridView, the OS does allow the user to drag and drop items, however nothing actually happens when the items are dropped.  

    Has anyone found a simple way to get this working?   Or any examples of how to possibly handle Drop events to manually reorganize the items in the collection?  

    Thanks
    Jeremy

    Friday, December 06, 2013 6:34 PM