Carousel
A 3D carousel: the items stand around a circle and the selected one faces the viewer.
public partial class Carousel : ItemsControl
Inherits from / implements: ItemsControl
Remarks
How this control works. An ItemsControl whose items are not laid out by a panel. Each item's container is an ordinary WPF element that is never shown: it is painted onto a VisualBrush, the brush becomes the material of a flat 3D rectangle, and the rectangle is what the user sees, arranged around a circle in a Viewport3D. PrepareContainerForItemOverride builds the model and remembers it on the container; ClearContainerForItemOverride takes it away again. The two pieces every item needs - the model and the four-part storyboard that moves it - come out of Core/CarouselResources.xaml, which is loaded ONCE into a static dictionary. Both entries are x:Shared="False", so every lookup hands back a new instance. Without that the whole carousel would share one model and one storyboard, and the animation targets rewritten per item would fight each other. The storyboards are aimed by property PATH, not by object: the path indexes into the container's Children collection, so it names "the transform of the item at index n". That is why PrepareTemplateStoryboard rebuilds the paths for every item on every move. The reflection is drawn by the control, not by the item template, so it works for any item - including one that is its own container and never uses a template. The model is twice as tall while the reflection is on, which is why the geometry is rebuilt with it. The front item is left unrotated (GetElementSpaceAtCurrentState sets no angle) while every other item is turned by ItemRenderAngle. That is the whole of the "current item faces you" effect.
Members at a glance
Carousel | Initializes a new instance of the Carousel class. |
Camera | Gets or sets the PerspectiveCamera object for the carousel. |
CarouselViewport3DAmbientLightColor | Gets or sets the color of the carousel viewport 3D ambient light. |
CarouselViewport3DCamera | Gets or sets the carousel viewport 3D PerspectiveCamera object. |
DistanceFromCentreToUser | Gets or sets the distance from centre of the carousel viewport, to the viewing user. |
GapBetweenCurrentDisplayFrontItemAndOthers | Gets or sets the gap between current display item in the front and others in the background. |
GapBetweenItems | Gets or sets the gap between items. |
IsReflectionRenderingEnabled | Gets or sets a value indicating whether each item is drawn with a reflection below it, fading to transparent. |
ItemDimension | Gets or sets the carousel item dimension. |
ItemRenderAngle | Gets or sets the item render angle. |
SelectedIndex | Gets or sets the index of the selected carousel item. |
VisualChildrenCount | Gets how many visual children this element has. |
ClearContainerForItemOverride | Undoes what PrepareContainerForItemOverride did, before the container is recycled. |
OnApplyTemplate | Called once the control template has been applied, which is where the named parts of the template first become reachable. |
OnMouseWheel | Raises the MouseWheel event. Carousel overrides it so the control's own handling runs alongside the base behavior. |
PrepareContainerForItemOverride | Applies this control's own settings to a container before the item it holds is shown. |
SelectedIndexChanged | Occurs when the selected index in the carousel has changed. |
CameraProperty | CameraProperty DependencyProperty |
CarouselViewport3DAmbientLightColorProperty | CarouselViewport3DAmbientLightColorProperty DependencyProperty |
CarouselViewport3DCameraProperty | CarouselViewport3DCameraProperty DependencyProperty |
DistanceFromCentreToUserProperty | DistanceFromCentreToUserProperty DependencyProperty |
GapBetweenCurrentDisplayFrontItemAndOthersProperty | GapBetweenCurrentDisplayFrontItemAndOthersProperty DependencyProperty |
GapBetweenItemsProperty | GapBetweenItemsProperty DependencyProperty |
IsReflectionRenderingEnabledProperty | IsReflectionRenderingEnabledProperty DependencyProperty |
ItemDimensionProperty | ItemDimensionProperty DependencyProperty |
ItemRenderAngleProperty | ItemRenderAngleProperty DependencyProperty |
MoveToLeft | MoveToLeft routed command |
MoveToRight | MoveToRight routed command |
SelectedIndexProperty | SelectedIndexProperty DependencyProperty |
Constructors
Carousel
Initializes a new instance of the Carousel class.
Properties
Camera
Gets or sets the PerspectiveCamera object for the carousel.
Value. The camera.
CarouselViewport3DAmbientLightColor
Gets or sets the color of the carousel viewport 3D ambient light.
CarouselViewport3DCamera
Gets or sets the carousel viewport 3D PerspectiveCamera object.
Value. The carousel viewport 3D camera.
DistanceFromCentreToUser
Gets or sets the distance from centre of the carousel viewport, to the viewing user.
Value. The distance from centre to user.
GapBetweenCurrentDisplayFrontItemAndOthers
Gets or sets the gap between current display item in the front and others in the background.
Value. The gap between current display front item and others.
GapBetweenItems
Gets or sets the gap between items.
Value. The gap between items.
IsReflectionRenderingEnabled
Gets or sets a value indicating whether each item is drawn with a reflection below it, fading to transparent.
Value. true if this instance is reflection rendering enabled; otherwise, false .
ItemDimension
Gets or sets the carousel item dimension.
Value. The item dimension.
ItemRenderAngle
Gets or sets the item render angle.
Value. The item render angle.
SelectedIndex
Gets or sets the index of the selected carousel item.
Value. The index of the selected carousel item.
VisualChildrenCount
Gets how many visual children this element has.
Methods
ClearContainerForItemOverride
Undoes what PrepareContainerForItemOverride did, before the container is recycled.
OnApplyTemplate
Called once the control template has been applied, which is where the named parts of the template first become reachable.
OnMouseWheel
Raises the MouseWheel event. Carousel overrides it so the control's own handling runs alongside the base behavior.
- e
- The data for the event.
PrepareContainerForItemOverride
Applies this control's own settings to a container before the item it holds is shown.
Events
SelectedIndexChanged
Occurs when the selected index in the carousel has changed.
Fields
CameraProperty
CameraProperty DependencyProperty
CarouselViewport3DAmbientLightColorProperty
CarouselViewport3DAmbientLightColorProperty DependencyProperty
CarouselViewport3DCameraProperty
CarouselViewport3DCameraProperty DependencyProperty
DistanceFromCentreToUserProperty
DistanceFromCentreToUserProperty DependencyProperty
GapBetweenCurrentDisplayFrontItemAndOthersProperty
GapBetweenCurrentDisplayFrontItemAndOthersProperty DependencyProperty
GapBetweenItemsProperty
GapBetweenItemsProperty DependencyProperty
IsReflectionRenderingEnabledProperty
IsReflectionRenderingEnabledProperty DependencyProperty
ItemDimensionProperty
ItemDimensionProperty DependencyProperty
ItemRenderAngleProperty
ItemRenderAngleProperty DependencyProperty
MoveToLeft
MoveToLeft routed command
MoveToRight
MoveToRight routed command
SelectedIndexProperty
SelectedIndexProperty DependencyProperty