Skip to main content
Version: 4.2

SegmentedButton

Namespace: Wisej.Web

Assembly: Wisej.Framework (4.2.0.0)

Displays a compact row of exclusive or multiple choices.

public class SegmentedButton : Control

Selection follows segment identity across collection edits. Removing a selected segment clears that selection. Disabled items retain selection and can be selected programmatically. No option is selected automatically. AllowDeselect constrains user activation only; server code may always clear selection.

Example:

var choices = new SegmentedButton { Appearance = SegmentAppearance.Outlined };
choices.Items.Add(new Segment { Text = "1H", Value = 1 });
choices.Items.Add(new Segment { Text = "24H", Value = 24 });
choices.SelectedIndex = 1;
choices.SelectionChanged += (s, e) => MessageBox.Show(choices.SelectedItem?.Text);
Controls.Add(choices);

Constructors​

Instance member SegmentedButton()​

Creates an empty selector with medium raised options.

Properties​

Instance member AllowDeselect​

Boolean: Gets or sets whether user activation may remove the final selection. (Default: False)

Instance member Appearance​

SegmentAppearance: Gets or sets the raised, outlined, or pill presentation. (Default: Raised)

Protected member DefaultSize​

Size: Gets the default 300 by 48 pixel size, including room around focused options.

Instance member Focusable​

Boolean: Gets or sets container focusability. Child options remain focusable. (Default: False)

Instance member Items​

SegmentCollection: Gets the owned, ordered options. Property edits automatically update the widget.

Instance member SegmentSize​

SegmentSize: Gets or sets the option padding and minimum height, independently of Control.Size. (Default: Medium)

Instance member SelectedIndex​

Int32: Gets the first selected index or sets the sole selected option; -1 clears all selection. (Default: -1)

The setter replaces selection even in Multiple mode. Use SetSelected to add or remove individual selections.

Instance member SelectedIndices​

Int32[]: Gets a snapshot of selected indexes in collection order.

Instance member SelectedItem​

Segment: Gets the first selected item or sets the sole selected option; null clears selection.

Instance member SelectedItems​

Segment[]: Gets a snapshot of selected items in collection order.

Instance member SelectionMode​

SegmentSelectionMode: Gets or sets single or multiple selection. Switching to One retains only the first selected item. (Default: One)

Instance member Stretch​

Boolean: Gets or sets whether options share the full available width. (Default: False)

Instance member TabStop​

Boolean: Gets or sets whether the container participates in tab navigation. Child options have their own tab stops. (Default: False)

Methods​

Protected member Dispose(disposing)​

Releases item observation and ownership.

ParameterTypeDescription
disposingBooleanWhether managed resources are being released.

Protected member OnItemClick(e)​

Raises ItemClick, including overrides without subscribers.

ParameterTypeDescription
eSegmentEventArgsEvent data.

Protected member OnSelectedIndexChanged(e)​

Raises SelectedIndexChanged, including overrides without subscribers.

ParameterTypeDescription
eEventArgsEvent data.

Protected member OnSelectionChanged(e)​

Raises SelectionChanged, including overrides without subscribers.

ParameterTypeDescription
eEventArgsEvent data.

Protected member OnWebEvent(e)​

Dispatches client activation independently of event subscription.

ParameterTypeDescription
eWisejEventArgsClient event.

Protected member OnWebRender(config)​

Serializes the option and selection snapshot without application values.

ParameterTypeDescription
configObjectClient configuration.

Protected member ResolveEventItem(e)​

Resolves a current enabled client item, rejecting stale and malformed event payloads.

ParameterTypeDescription
eWisejEventArgsClient event.

Returns: Segment. The matching item, or null.

Instance member SetSelected(index, value)​

Adds or removes an individual selection. Selecting in One mode replaces the previous selection.

ParameterTypeDescription
indexInt32An existing item index.
valueBooleanTrue selects; false deselects, regardless of AllowDeselect.

Example:

choices.SelectionMode = SegmentSelectionMode.Multiple;
choices.SetSelected(0, true);
choices.SetSelected(2, true);

Protected member ViewChanged()​

Requests a new client snapshot after a presentation property changes.

Events​

Instance member ItemClick​

EventHandler<SegmentEventArgs> Occurs after user activation and its selection notifications, if the activated item still exists and is enabled.

Instance member SelectedIndexChanged​

EventHandler Occurs when the first selected collection index changes.

Instance member SelectionChanged​

EventHandler Occurs when selected segment identities change.

Inherited By​

NameDescription
ChipGroupDisplays wrapping selectable chips with optional counts and close buttons.

Implements​

NameDescription
IUserDataProvides access to the UserData and Tag properties associated to the component implementing this interface.
IBindableComponentBindable components implement this interface.
IDropTargetControls that support drag & drop operations implement this interface.
IWisejComponentAll wisej components implement this interface.
IWisejControlAll wisej controls derived from the Control class must implement this interface.
IWisejSerializableAllows an object to serialize itself.