Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1871
Reorder items under group
posted

I am trying to write code to reorder the items under a single group. We use our own custom popup menu to accomplish this. I have three items under a group called sessions.

For Instance:

Session 1

Session 2

Session 3

When I right click on Session 3 to move it up. It moves Session 3 above Session 2 but leaves an extra Session 3.

I end up with:

Session 1

Session 3

Session 2

Session 3

The last item is actually not there it appears not to refresh the items correctly.

I have attached sample code to show how I am trying to accomplish. Any suggestions would be greatly appreciated.

Thanks.

ExplorerBarReorder.zip
Parents
  • 469350
    Verified Answer
    Offline posted

    Hi Michael,

    The problem is in your code. In your BuildContextMenu method, you have this:

    this.explorerBarItem = selectedItem.Clone();

    So you are not storing the actual item in the ExplorerBar, you are creating a clone. So your Remove method doesn't work, because you are removing a clone of the original item and that clone does not exist in the collection.

    So you can either just store the actual item (without cloning it). Or you could change your Remove to RemoveAt and just remove based on the Index.

Reply Children
No Data