Skip to main content

SelectorBar

C# API / Fluence.Wpf.Controls

  • Assembly: Fluence.Wpf
  • Namespace: Fluence.Wpf.Controls
public class SelectorBar : ListBox

A horizontal row of peer destinations, mirroring the WinUI 3 SelectorBar: one SelectorBarItem per destination, exactly one of them selected, with an accent pill under the selected label. Use it to switch between sibling views of the same page rather than to host the views themselves.

Remarks: The control derives from ListBox, so selection, keyboard navigation, and the selection automation pattern come from the framework. WinUI's SelectorBar is always single-select, so SelectionMode is coerced to Single and a consumer cannot widen it.

Items may be declared inline as SelectorBarItem elements or come from ItemsSource. For a generated container the label is bound to DisplayMemberPath when one is set (honouring ItemStringFormat) and taken from the item's own string form otherwise, because the WinUI-shaped Text is what the default template presents rather than the inherited content.

Base type: ListBox

C# source

Constructors​

SelectorBar​

public SelectorBar()

Creates a new SelectorBar instance.

Methods​

GetContainerForItemOverride​

protected override DependencyObject GetContainerForItemOverride()

Documentation inherited from the ListBox API.

IsItemItsOwnContainerOverride​

protected override bool IsItemItsOwnContainerOverride(object item)

Documentation inherited from the ListBox API.

OnGotKeyboardFocus​

protected override void OnGotKeyboardFocus(KeyboardFocusChangedEventArgs e)

Documentation inherited from the ListBox API.

Remarks: WinUI's SelectorBar selects the current item, or the first one, when the bar takes focus with nothing selected (SelectorBar.cpp OnGotFocus), so a keyboard user never lands on a bar with no pill.

OnSelectionChanged​

protected override void OnSelectionChanged(SelectionChangedEventArgs e)

Documentation inherited from the ListBox API.

Remarks: The bar never settles with nothing selected. SelectorBarItem already swallows the two deselect gestures WPF's ListBox honours in Single, so this is the net under anything else that empties the selection: the item that just left is put back, because the pill is the page's current destination and WinUI's SelectorBar has no state without one.

PrepareContainerForItemOverride​

protected override void PrepareContainerForItemOverride(DependencyObject element, object item)

Documentation inherited from the ListBox API.