Windows Phone 8.1 (WinRT): Custom Looping Selector

人盡茶涼 提交于 2019-12-18 19:05:31

问题


I want a custom Looping Selector for my Windows Phone 8.1 (WinRT) and I couldn't find any solution for the moment. I want something like this:

The Windows Phone Toolkit is for WP8.0 and WP8.1 Silverlight and it doesn't work for WP8.1 (WinRT) apps (And this question is for WP8.1 Silverlight).

There are DatePicker & TimePicker controls for WP8.1. Is there any way to custom their data or something to trick the control to my problem?

There is a LoopingSelector class but it seems that it is not implemented yet.

Any solution or idea would be appreciated.


回答1:


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




回答2:


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!



来源:https://stackoverflow.com/questions/27729182/windows-phone-8-1-winrt-custom-looping-selector

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