在Windows手机中拖动和重新排序列表框项目

时间:2013-09-16 12:50:15

标签: windows-phone-8 drag-and-drop listbox

我一直在寻找一个拖放列表框,但我想没有这样的默认控件。有点搜索给了我Jason's Blog,他在其中非常优雅地将它拉出来。在他编写的代码中,有一个拖放处理程序,它出现在每个listboxitem的右端。你按下处理程序并向上或向下移动项目。我试图在长按该项目时实现相同的目标..

他使用了一个基本上是画布的拖拽拦截器,它位于列表框的顶部以捕获listboxitem操作事件。如果我想对列表框项的hold事件进行相同的操作,我该如何触发?

这就是我将事件链接到阻力拦截器的方法。 如何在列表框项目的控制下调用Manipulation Started?或者还有其他方法可以做到这一点吗?

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

2 个答案:

答案 0 :(得分:1)

一旦触发了hold事件,您是否尝试过仅添加操作事件处理程序?或者添加一个在Hold上设置并在ManipulationCompleted上清除的标志,以测试在其他操作事件中运行主代码之前是否已完成保留。

答案 1 :(得分:1)

我通过从mainpage.xaml发送参数(object sender和ManipulationStartedEventArgs)来触发重新排序列表框的操作事件。

相关问题