Dragging and reordering listbox items in Windows phone

感情迁移 提交于 2019-12-11 02:10:02

问题


I have been looking for a drag and drop listbox, but I guess there is no such default control. A bit of searching has given me,Jason's Blog in which he has pulled it off very gracefully.. In the code he has written, there is a the drag and drop handler which is present at the right end of every listboxitem.. You press on the handler and move the item up or down. I am trying to implement the same on the long press of the item..

He uses a drag interceptor which is basically a canvas and it sits on top of listbox to capture the listboxitem manipulation events. If I want the same manipulation on the hold event of the listbox item, how do I trigger it??

This is how I have linked the events to the drag interceptor. How do i call the Manipulation Started on the hold of the listbox item?? Or is there some other way to do this?

this.dragInterceptor.ManipulationStarted += this.dragInterceptor_ManipulationStarted;
this.dragInterceptor.ManipulationDelta += this.dragInterceptor_ManipulationDelta;
this.dragInterceptor.ManipulationCompleted += this.dragInterceptor_ManipulationCompleted;
this.dragInterceptor.Hold += dragInterceptor_Hold;

回答1:


Have you tried only adding the manipulation event handlers once the hold event is triggered? Or adding a flag which is set on Hold and cleared on ManipulationCompleted to test if the hold was done before running the main code in the other manipulation events.




回答2:


I triggered the manipulation events of the reorder listbox by sending the arguments (object sender and ManipulationStartedEventArgs) from the mainpage.xaml.



来源:https://stackoverflow.com/questions/18828530/dragging-and-reordering-listbox-items-in-windows-phone

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!