Table of Contents

Class Selector<WidgetType, ItemType>

Namespace
Myra.Graphics2D.UI
Assembly
Myra.dll

An abstract implementation of a selector widget that manages a collection of selectable items.

public abstract class Selector<WidgetType, ItemType> : SelectorBase<WidgetType, ItemType>, IItemWithId, INotifyAttachedPropertyChanged where WidgetType : Widget where ItemType : class, ISelectorItem

Type Parameters

WidgetType

The type of widget to display the items.

ItemType

The type of items that can be selected.

Inheritance
SelectorBase<WidgetType, ItemType>
Selector<WidgetType, ItemType>
Implements
Derived
Inherited Members

Constructors

Selector(WidgetType)

Initializes a new instance of the Selector<WidgetType, ItemType> class.

protected Selector(WidgetType widget)

Parameters

widget WidgetType

The widget to display and manage the items.

Properties

Items

Gets the collection of selectable items.

public override ObservableCollection<ItemType> Items { get; }

Property Value

ObservableCollection<ItemType>

SelectedIndex

Gets or sets the zero-based index of the currently selected item, or null if no item is selected.

public override int? SelectedIndex { get; set; }

Property Value

int?

SelectedItem

Gets or sets the currently selected item, or null if no item is selected.

public override ItemType SelectedItem { get; set; }

Property Value

ItemType

SelectionMode

Gets or sets the selection mode (single or multiple items).

public override SelectionMode SelectionMode { get; set; }

Property Value

SelectionMode

Methods

InsertItem(ItemType, int)

Inserts an item at the specified index. Derived classes must implement this method.

protected abstract void InsertItem(ItemType item, int index)

Parameters

item ItemType

The item to insert.

index int

The zero-based index where the item should be inserted.

OnItemCollectionChanged()

Called when the items collection changes. Raises the ItemsCollectionChanged event.

protected virtual void OnItemCollectionChanged()

OnSelectedItemChanged()

Called when the selected item changes. Derived classes can override to perform custom behavior.

protected virtual void OnSelectedItemChanged()

RemoveItem(ItemType)

Removes the specified item from the selector. Derived classes must implement this method.

protected abstract void RemoveItem(ItemType item)

Parameters

item ItemType

The item to remove.

Reset()

Clears all items from the selector. Derived classes must implement this method.

protected abstract void Reset()

Events

ItemsCollectionChanged

Occurs when the items collection is modified.

public event MyraEventHandler ItemsCollectionChanged

Event Type

MyraEventHandler

SelectedIndexChanged

Occurs when the selected item or selected index changes.

public override event MyraEventHandler SelectedIndexChanged

Event Type

MyraEventHandler