Class SelectionModel<T>
public class SelectionModel<T> : SelectionNodeBase<T>, ISelectionModel, INotifyPropertyChanged
Type Parameters
T
- Inheritance
-
SelectionModel<T>
- Implements
- Inherited Members
- Extension Methods
Constructors
SelectionModel()
public SelectionModel()
SelectionModel(IEnumerable<T>?)
public SelectionModel(IEnumerable<T>? source)
Parameters
source
IEnumerable<T>
Properties
AnchorIndex
public int AnchorIndex { get; set; }
Property Value
Count
public int Count { get; }
Property Value
SelectedIndex
public int SelectedIndex { get; set; }
Property Value
SelectedIndexes
public IReadOnlyList<int> SelectedIndexes { get; }
Property Value
SelectedItem
public T? SelectedItem { get; set; }
Property Value
- T
SelectedItems
public IReadOnlyList<T?> SelectedItems { get; }
Property Value
SingleSelect
public bool SingleSelect { get; set; }
Property Value
Source
public IEnumerable? Source { get; set; }
Property Value
Methods
BatchUpdate()
public SelectionModel<T>.BatchUpdateOperation BatchUpdate()
Returns
BeginBatchUpdate()
public void BeginBatchUpdate()
Clear()
public void Clear()
Deselect(int)
public void Deselect(int index)
Parameters
index
int
DeselectRange(int, int)
public void DeselectRange(int start, int end)
Parameters
EndBatchUpdate()
public void EndBatchUpdate()
IsSelected(int)
public bool IsSelected(int index)
Parameters
index
int
Returns
OnIndexesChanged(int, int)
Called by OnSourceCollectionChanged(NotifyCollectionChangedEventArgs), detailing the indexes changed by the collection changing.
protected override void OnIndexesChanged(int shiftIndex, int shiftDelta)
Parameters
shiftIndex
intThe first index that was shifted.
shiftDelta
intIf positive, the number of items inserted, or if negative the number of items removed.
OnItemsAdded(int, IList)
Called by OnSourceCollectionChanged(NotifyCollectionChangedEventArgs) when items are added to the source collection.
protected override SelectionNodeBase<T>.CollectionChangeState OnItemsAdded(int index, IList items)
Parameters
Returns
- SelectionNodeBase<T>.CollectionChangeState
A SelectionNodeBase<T>.CollectionChangeState struct containing the details of the adjusted selection.
Remarks
The implementation in SelectionNodeBase<T> adjusts the selected ranges, assigning new indexes. Override this method to carry out additional computation when items are added.
OnSelectionRemoved(int, int, IReadOnlyList<T>)
Called by OnSourceCollectionChanged(NotifyCollectionChangedEventArgs), detailing the items removed by a collection change.
protected override void OnSelectionRemoved(int index, int count, IReadOnlyList<T> deselectedItems)
Parameters
index
intcount
intdeselectedItems
IReadOnlyList<T>
OnSourceCollectionChangeFinished()
Called when the source collection has finished changing, and all CollectionChanged handlers have run.
protected override void OnSourceCollectionChangeFinished()
Remarks
Override this method to respond to the end of a collection change instead of acting at the end of OnSourceCollectionChanged(NotifyCollectionChangedEventArgs) in order to ensure that all UI subscribers to the source collection change event have had chance to run.
OnSourceCollectionChangeStarted()
Called when the source collection starts changing.
protected override void OnSourceCollectionChangeStarted()
OnSourceCollectionChanged(NotifyCollectionChangedEventArgs)
Called when the Source collection changes.
protected override void OnSourceCollectionChanged(NotifyCollectionChangedEventArgs e)
Parameters
e
NotifyCollectionChangedEventArgsThe details of the collection change.
Remarks
The implementation in SelectionNodeBase<T> calls OnItemsAdded(int, IList) and OnItemsRemoved(int, IList) in order to calculate how the collection change affects the currently selected items. It then calls OnIndexesChanged(int, int) and OnSelectionRemoved(int, int, IReadOnlyList<T>) if necessary, according to the SelectionNodeBase<T>.CollectionChangeState returned by those methods.
Override this method and OnSourceCollectionChangeFinished() to provide custom handling of source collection changes.
OnSourceReset()
Called by OnSourceCollectionChanged(NotifyCollectionChangedEventArgs), on collection reset.
protected override void OnSourceReset()
RaisePropertyChanged(string)
protected void RaisePropertyChanged(string propertyName)
Parameters
propertyName
string
Select(int)
public void Select(int index)
Parameters
index
int
SelectAll()
public void SelectAll()
SelectRange(int, int)
public void SelectRange(int start, int end)
Parameters
Events
IndexesChanged
public event EventHandler<SelectionModelIndexesChangedEventArgs>? IndexesChanged
Event Type
LostSelection
public event EventHandler? LostSelection
Event Type
PropertyChanged
public event PropertyChangedEventHandler? PropertyChanged
Event Type
SelectionChanged
public event EventHandler<SelectionModelSelectionChangedEventArgs<T>>? SelectionChanged
Event Type
SourceReset
public event EventHandler? SourceReset