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:
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.
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.
That fixed it. I think I tried cloning the item because the index would change from 2 to a -1. So when I went to remove it the index was incorrect. Thanks for your help.