Skip to content

Carousel

Carousel is an item host with prev/next chevrons, dot indicators, and ArrowLeft/ArrowRight keyboard navigation. It derives Selector directly (the same WPF base ListBox/TabControl use) rather than a bespoke “current index” property, so it gets SelectedIndex/SelectedItem as bindable dependency properties for free; the template’s ItemContainerStyle uses Selector.IsSelected to show only the current slide, fade transitions when allowed, and light the matching dot. An outgoing slide becomes Collapsed after its 150ms fade, so inactive descendants leave the UI Automation tree instead of remaining discoverable at zero opacity. Reduced motion swaps visibility immediately. Slides are added directly as UIElement items (each item is its own container). Pointer-swipe physics are explicitly out of scope; only the chevrons, dots, and keyboard arrows drive navigation.

xmlns:carousel="clr-namespace:Navius.Wpf.Ui.Carousel;assembly=Navius.Wpf.Ui"
<carousel:NaviusCarousel Height="160">
<Border Background="{DynamicResource Navius.Muted}">
<TextBlock Text="Slide 1" HorizontalAlignment="Center" VerticalAlignment="Center" />
</Border>
<Border Background="{DynamicResource Navius.Muted}">
<TextBlock Text="Slide 2" HorizontalAlignment="Center" VerticalAlignment="Center" />
</Border>
</carousel:NaviusCarousel>
Property Type Default From Description
Loop bool true NaviusCarousel Whether Next from the last slide wraps to the first (and Previous from the first wraps to the last).
ShouldAnimate bool Windows preference NaviusCarousel Read-only snapshot of the styled layer’s reduced-motion policy. false removes both enter and exit fades.
Items ItemCollection empty ItemsControl (via Selector) Populated directly with UIElement slides; each item is its own container (IsItemItsOwnContainerOverride returns true for UIElement).
SelectedIndex int -1 Selector Bindable current-slide index. Auto-initializes to 0 the first time items appear (an empty carousel with slides and nothing selected would read as broken).
Command Description
NaviusCarousel.PreviousCommand Moves to the previous slide (wraps if Loop). Bound to the template’s left chevron button.
NaviusCarousel.NextCommand Moves to the next slide (wraps if Loop). Bound to the template’s right chevron button.
NaviusCarousel.GoToSlideCommand Selects the slide at the int index passed as the command parameter. Bound to each dot indicator, parameterized via its ItemsControl.AlternationIndex.
Key Behavior
Left Arrow Moves toward the visual left; previous in LTR and next in RTL (wraps if Loop).
Right Arrow Moves toward the visual right; next in LTR and previous in RTL (wraps if Loop).

NaviusCarousel does not override OnCreateAutomationPeer, and Selector itself does not supply one either (only concrete selector controls like ListBox do), so the control falls back to ItemsControl’s peer, ItemsControlAutomationPeer, reporting AutomationControlType.List. The previous/next buttons are named “Previous slide” and “Next slide”; dot buttons use one-based “Slide N” names and the selected dot reports AutomationProperties.ItemStatus="current". Inactive slide containers are Collapsed after the transition, which removes their descendants from UIA Control/Content views. A FlaUI test selects the next slide and proves the old slide action disappears while the new action becomes discoverable. The unit suite exercises CarouselEngine.MoveIndex (the pure index-wrap math backing both Loop directions and the no-loop clamp), default Loop/SelectedIndex values, auto-selection of the first slide once items are added, and GoToSlideCommand selection (tests/Navius.Wpf.Tests/UiCompositeTests.cs).

  • Pointer-swipe physics are explicitly out of scope for this control; only the chevrons, dots, and keyboard arrows drive navigation, unlike touch/pointer-swipe carousels on the web.
  • Windows reduced motion applies to the transient slide transition as well as looping motion. Animated selection preserves the 150ms fade; reduced selection changes visibility immediately.
  • Hiding a slide with opacity alone is not considered hidden from assistive technology. Inactive slides are Collapsed after the exit transition, and the behavior is pinned by real UIA coverage.