2013-09-16 103 views
2

我一直在寻找一个拖放列表框,但我想没有这样的默认控件。有一点搜索给了我,Jason's Blog,他已经非常优雅地把它关闭了。在他写的代码中,有一个拖放处理程序,它出现在每个listboxitem的右端。处理程序并向上或向下移动项目。我试图在长按项目上实现相同的效果。拖动和重新排序Windows Phone中的列表框项目

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

这就是我将事件链接到拦截拦截器的方法。 我如何调用手持开始的列表框项目?或者有其他方法可以做到这一点吗?

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

回答

1

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

+0

我试图只在触发后才添加manipulationevent ..并且它不起作用:(关于设置一个bool,问题是,ManipulationStarted在保持事件之前被调用。所以布尔检查变为无效:( – alfah

+0

由于Hold比操纵事件的级别更高,它看起来就像你需要使用计时器并根据计时器检测自己的hold(请参阅http://stackoverflow.com/questions/18846816/如何实现长按使用操纵事件在Windows电话-8/18851980?noredirect = 1#comment27815203_18851980)而不是使用事件。 –

1

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