Windows Phone 8.1 (WinRT): Custom Looping Selector

左心房为你撑大大i 提交于 2019-11-30 17:38:58

Not sure if you still need this... but there is a WinRT LoopItemsPanel project available here: http://blogs.msdn.com/b/mim/archive/2013/04/16/winrt-create-a-custom-itemspanel-for-an-itemscontrol.aspx

I did something like this for an "infinite snapping date selector" if that makes sense :)

Basics:

  • create a data model to display which can provide you with the next/previous elements
  • have a Canvas as your control root (it's fast)
  • call render Loaded and rerender on SizeChanged
  • create a (dependency)property for selected value
  • subscribe for relevant manipulation events (ManipulationDelta, and *Completed) and choose what ManipulationModes you want to allow (translate, maybe translateintertia if you want intertia)

Render:

  • render screensize/elementsize + 2 elements (maybe more)
  • move them on the manipulationdelta and completed events
  • if an element leaves the control boundary on one side, move the last element on that side to the other end, while changing the displayed data as well (basically if it was the last, than firstelement.getprevious)
  • on manipulationcompleted find the closest element to the center, and animate everything to a 'snap' position
  • and finally set your selectedvalue property to the data of the centered element

This solution with animating Canvas.Left performed well even on a first-gen Surface RT. Good luck!

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