ListViewBase中的CanReorderItems属性

最近使用GridView时,想实现Item之间的自由拖动排列,一开始自己写了个Panel,后来才发现自带的API中已经有了这么一个属性CanReorderItems,然而在设置为true之后,不没有能使Item自由排列,google了一下才找到原因。

下面是来自http://www.itq.nl/blogs/post/CanReorderItems3dtrue.aspx中的解释

But, there are some things you need to know to get it to work. First of all the AllowDrop property also needs to be set to true.

And the grid or list needs to be binded to a ObservableVector (no ObservableCollection is not good enough). But in the developer preview only an interface exists for this collection, so you have to make your own implementation or borrow one.. like this one.

One caveat remains.. the ObservableVector needs to be initialized with object as T, strong types will not work in the developer preview of windows 8. Like so:

简单易懂,就不翻译了=。=

但使用过程中有以下注意点(http://msdn.microsoft.com/zh-cn/library/windows/apps/windows.ui.xaml.controls.listviewbase.canreorderitems.aspx

  • 如果启用了项目选择,并且将 IsSwipeEnabled 设置为 false,则用户可以通过鼠标右击来取消选择项目,但是不能通过重击手势,使用触控来取消选择项目。
  • 如果将 CanDragItems 设置为 true,并将 IsSwipeEnabled 设置为 false,则用户可以用鼠标拖动项目,但不能通过触摸方式。
  • 如果将 CanReorderItems 设置为 true,并将 IsSwipeEnabled 设置为 false,则用户可以用鼠标对项目重新排序,但不能通过触摸方式。
posted @ 2013-02-19 17:49  xudshen  阅读(361)  评论(0编辑  收藏  举报