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.
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 onSizeChanged
- create a (dependency)property for selected value
- subscribe for relevant manipulation events (
ManipulationDelta
, and*Completed
) and choose whatManipulationModes
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