开发者

How to traverse the item in the collection in a List or Observable collection?

I have a collection that is binded to my Listview.

I have provided options to user to "move up" "move down" the selected item in the list view. I have binded the selected item of the listview to my viewmodel, hence I get the item in the collection o开发者_Python百科n which user want to do the operation.

I have attached "move up" "move down" commands in my viewmodel.

I want what is the best way to move up and down in the collection in the collection which is reflected in the list view.

For example

If the selected item is the last item in the collection ( and in the list view) move the item to the top.

For this I have to create a new collection and reorder the items in the collection.

Please suggest.


You can do this by retrieving the index of the ObservableCollection corresponding to the selected item and swapping it with the previous item.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜