简体   繁体   English

在Silverlight中从列表框拖放到列表框

[英]Dragdrop from listbox to listbox in silverlight

I am using a listbox to bind the data coming from the database, once the binding is done there is another listbox where i have to drag and drop the contents of the first listbox. 我正在使用一个列表框来绑定来自数据库的数据,一旦绑定完成,就会有另一个列表框,我必须在其中拖放第一个列表框的内容。 I am able to drag and drop it but nothing is visible in the 2nd listbox(but the content is moving from the 1st to 2nd listbox). 我可以拖放它,但是在第二个列表框中什么都看不到(但是内容从第一个列表框移动到第二个列表框)。 The same thing i tried by hardcoding the items in the 1st listbox and everything worked fine. 我尝试通过对第一个列表框中的项目进行硬编码来尝试相同的事情,并且一切正常。 If anybody has experienced similar kind of problem, please help. 如果有人遇到过类似的问题,请提供帮助。

您将必须处理第二个列表框的ondrop事件,并且必须更新在drop事件中绑定到第二个列表框的集合。

Make sure you're using ObservableCollection when dragging and dropping between sources. 在源之间进行拖放时,请确保使用的是ObservableCollection。 If you used List, then the ListBoxes will not be notified of a change in the collection. 如果您使用了List,则不会通知ListBoxes集合中的更改。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM