Skip to main content

SelectorBarItem

C# API / Fluence.Wpf.Controls

  • Assembly: Fluence.Wpf
  • Namespace: Fluence.Wpf.Controls
public class SelectorBarItem : ListBoxItem

One selectable entry of a SelectorBar, mirroring the WinUI 3 SelectorBarItem: an optional icon, a text label, and an accent pill that grows out from the label centre while the item is selected.

Remarks: WinUI's SelectorBarItem carries Text and Icon rather than arbitrary content, and this port keeps that surface. The type still inherits Content from its ListBoxItem base, but the default template does not present it; an item generated for a plain data item instead takes its label from SelectorBar, which fills Text in when it prepares the container.

The selection pill is animated in code rather than from a template storyboard so the reveal can be skipped when motion is disabled, the pattern PipsPager already uses. WinUI plays the same reveal over its ComboBoxItemScaleAnimationDuration (167 ms) on the 0,0,0,1 key spline, scaling the pill from its 4 px rest width to four times that (SelectorBar.xaml SelectedNormal), and snaps straight back when the item is unselected.

Base type: ListBoxItem

C# source

Constructors​

SelectorBarItem​

public SelectorBarItem()

Creates a new SelectorBarItem instance.

Properties​

Icon​

public object? Icon { get; set; }

Gets or sets the icon shown before Text. The default template collapses the icon presenter while this is null, so a text-only item carries no leading gap.

Text​

public string? Text { get; set; }

Gets or sets the label shown beside the optional Icon.

Methods​

OnApplyTemplate​

public override void OnApplyTemplate()

Documentation inherited from the ListBoxItem API.

OnCreateAutomationPeer​

protected override AutomationPeer OnCreateAutomationPeer()

Documentation inherited from the ListBoxItem API.

OnPreviewKeyDown​

protected override void OnPreviewKeyDown(KeyEventArgs e)

Documentation inherited from the ListBoxItem API.

Remarks: The keyboard half of the same gesture: Ctrl+Space toggles selection on a WPF ListBoxItem, and toggling off is what WinUI does not offer.

OnPreviewMouseLeftButtonDown​

protected override void OnPreviewMouseLeftButtonDown(MouseButtonEventArgs e)

Documentation inherited from the ListBoxItem API.

Remarks: Swallows the Ctrl+Click deselect gesture on the item that already carries the pill. WPF's ListBox honours it even in Single, which would leave the bar with no selection at all; WinUI's SelectorBar has no deselect gesture, and the pill is the page's current destination. Ctrl+Click on any other item still moves the selection there.

OnSelected​

protected override void OnSelected(RoutedEventArgs e)

Documentation inherited from the ListBoxItem API.

OnUnselected​

protected override void OnUnselected(RoutedEventArgs e)

Documentation inherited from the ListBoxItem API.

Dependency property identifiers​

Use these identifiers with WPF property APIs. The matching CLR properties appear above when the control exposes them.

IconProperty​

public static readonly DependencyProperty IconProperty

Identifies the Icon dependency property.

TextProperty​

public static readonly DependencyProperty TextProperty

Identifies the Text dependency property.