在uwp中的两个列表框之间移动项目。 [英] Move items between two listboxes in uwp .

查看:72
本文介绍了在uwp中的两个列表框之间移动项目。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在右侧他们是listbox1,我选择了多个列表框项目(从数据库绑定的项目)。按钮单击我将listbox1项目移动到listbox2。那部分我做了。但我没有得到listbox2项目的ID。





所以如何获得listbox2项目的ID。



我尝试了什么:



移动项目从一个listbox1到listbox2成功完成现在问题是如何获取listbox2我想要的ID存储项目ID

in right hand side their is listbox1 and i am selecting the multiple listbox items(items bind from the database). on button click i am moving listbox1 items to listbox2. that part i have done. but i am not getting the ids of listbox2 items.


so how to get the ids of listbox2 items.

What I have tried:

moving items form one listbox1 to listbox2 done successfully now problem is how to get the ids of listbox2 i want to store the items ids

推荐答案

通常,如果我这样做,我会维护两个ObservableCollections,一个绑定到第一个ListBox,第二个绑定到第二个列表框。然后,当我想在ListBox之间移动项目时,我会从第一个ObservableCollection中删除该项目并将其添加到第二个ObservableCollection中。移动的外观是通过绑定的魔力自动处理的,然后我会对ObservableCollection中的实际元素进行处理,而不是试图破解回ListBox。
Normally, if I were doing something like this, I would maintain two ObservableCollections, one bound to the first ListBox and the second bound to the second ListBox. Then, when I wanted to move items between the ListBoxes, I would remove the item from the first ObservableCollection and add it into the second ObservableCollection. The appearance of moving is handled automatically through the magic of binding and I would then do processing against the actual elements in the ObservableCollection, rather than trying to hack back into the ListBox.


这篇关于在uwp中的两个列表框之间移动项目。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆