Class SelectableCollectionViewModel<T>
View model class for representing a collection of objects that implements ISelectable. By default it only allows one item to be selected at a time and it will
manage the IsSelected property of the items in the collection. If you want to allow multiple selections, set AllowMultipleSelections to true.
Inheritance
SelectableCollectionViewModel<T>
Assembly: Benday.Presentation.dll
Syntax
public class SelectableCollectionViewModel<T> : ViewModelBase, INotifyPropertyChanged where T : class, ISelectable
Type Parameters
Constructors
|
Edit this page
View Source
SelectableCollectionViewModel()
Declaration
public SelectableCollectionViewModel()
|
Edit this page
View Source
SelectableCollectionViewModel(ObservableCollection<T>)
Initializes a new instance of the SelectableCollectionViewModel class with existing items or an existing ObservableCollection instance.
Declaration
public SelectableCollectionViewModel(ObservableCollection<T> values)
Parameters
Exceptions
|
Edit this page
View Source
SelectableCollectionViewModel(ObservableCollection<T>, T)
Initializes a new instance of the SelectableCollectionViewModel class with existing items or an existing ObservableCollection instance.
Declaration
public SelectableCollectionViewModel(ObservableCollection<T> values, T selectedItem)
Parameters
Type |
Name |
Description |
ObservableCollection<T> |
values |
|
T |
selectedItem |
Item in the values collection that should be selected
|
Exceptions
Fields
|
Edit this page
View Source
ItemsPropertyName
Declaration
public readonly string ItemsPropertyName
Field Value
|
Edit this page
View Source
_Items
Declaration
protected ObservableCollection<T>? _Items
Field Value
Properties
|
Edit this page
View Source
AllowMultipleSelections
Gets or sets a value indicating whether multiple selections are allowed.
Declaration
public bool AllowMultipleSelections { get; set; }
Property Value
|
Edit this page
View Source
Count
Gets the number of items in the collection.
Declaration
public int Count { get; }
Property Value
|
Edit this page
View Source
HasOnItemSelectedSubscriber
Utility property to determine if the view model has a subscriber to the OnItemSelected event.
Declaration
public bool HasOnItemSelectedSubscriber { get; }
Property Value
|
Edit this page
View Source
IsEnabled
Gets or sets a value indicating whether this view model is enabled.
Declaration
public bool IsEnabled { get; set; }
Property Value
|
Edit this page
View Source
IsValid
Gets or sets a value indicating whether this view model is valid.
NOTE: this property does not do any validation, it is just a flag that can be used by the view.
Declaration
public bool IsValid { get; set; }
Property Value
|
Edit this page
View Source
Items
Gets or sets the collection of items.
Declaration
public ObservableCollection<T> Items { get; protected set; }
Property Value
|
Edit this page
View Source
SelectedItem
Gets or sets the selected item.
Declaration
public T? SelectedItem { get; set; }
Property Value
Methods
|
Edit this page
View Source
Add(T)
Adds an item to the collection.
Declaration
public void Add(T addThis)
Parameters
Type |
Name |
Description |
T |
addThis |
|
Exceptions
|
Edit this page
View Source
Clear()
Declaration
|
Edit this page
View Source
GetSelectedItems()
Declaration
public List<T> GetSelectedItems()
Returns
Type |
Description |
List<T> |
Selected items in a new instance of List
|
|
Edit this page
View Source
Initialize(IEnumerable<T>)
Resets the collection to the specified values.
Declaration
public virtual void Initialize(IEnumerable<T> values)
Parameters
|
Edit this page
View Source
OnItemPropertyChanged(object?, PropertyChangedEventArgs)
Declaration
protected virtual void OnItemPropertyChanged(object? sender, PropertyChangedEventArgs e)
Parameters
|
Edit this page
View Source
RefreshSelectedItem(bool)
Declaration
protected void RefreshSelectedItem(bool directAssign = false)
Parameters
Type |
Name |
Description |
bool |
directAssign |
|
|
Edit this page
View Source
Remove(T)
Removes an item from the collection.
Declaration
public void Remove(T removeThis)
Parameters
Type |
Name |
Description |
T |
removeThis |
|
Exceptions
Events
|
Edit this page
View Source
OnItemSelected
Event that is raised when an item is selected.
Declaration
public event EventHandler? OnItemSelected
Event Type
Implements