Class SingleSelectListViewModel
A view model that can be selected. This is useful for list boxes and combo boxes when you want to bind to a list of items.
Inheritance
Inherited Members
Namespace: Benday.Presentation
Assembly: Benday.Presentation.dll
Syntax
public class SingleSelectListViewModel : SelectableCollectionViewModel<ISelectableItem>, INotifyPropertyChanged, IVisibleField
Constructors
| Edit this page View SourceSingleSelectListViewModel()
Initializes a new instance of the SingleSelectListViewModel class with an empty collection.
Declaration
protected SingleSelectListViewModel()
SingleSelectListViewModel(IEnumerable<ISelectableItem>)
Initializes a new instance of the SingleSelectListViewModel class with the specified items.
Declaration
public SingleSelectListViewModel(IEnumerable<ISelectableItem> values)
Parameters
| Type | Name | Description |
|---|---|---|
| IEnumerable<ISelectableItem> | values | The items to populate the collection with. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown when values is null. |
SingleSelectListViewModel(IEnumerable<ISelectableItem>, ISelectableItem)
Initializes a new instance of the SingleSelectListViewModel class with the specified items and a selected item.
Declaration
public SingleSelectListViewModel(IEnumerable<ISelectableItem> values, ISelectableItem selectedItem)
Parameters
| Type | Name | Description |
|---|---|---|
| IEnumerable<ISelectableItem> | values | The items to populate the collection with. |
| ISelectableItem | selectedItem | The item to select initially. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown when values or selectedItem is null. |
SingleSelectListViewModel(ObservableCollection<ISelectableItem>)
Initializes a new instance of the SingleSelectListViewModel class with an existing ObservableCollection.
Declaration
public SingleSelectListViewModel(ObservableCollection<ISelectableItem> values)
Parameters
| Type | Name | Description |
|---|---|---|
| ObservableCollection<ISelectableItem> | values | The ObservableCollection to use as the backing collection. |
SingleSelectListViewModel(ObservableCollection<ISelectableItem>, ISelectableItem)
Initializes a new instance of the SingleSelectListViewModel class with an existing ObservableCollection and a selected item.
Declaration
public SingleSelectListViewModel(ObservableCollection<ISelectableItem> values, ISelectableItem selectedItem)
Parameters
| Type | Name | Description |
|---|---|---|
| ObservableCollection<ISelectableItem> | values | The ObservableCollection to use as the backing collection. |
| ISelectableItem | selectedItem | The item to select initially. |
Properties
| Edit this page View SourceIsVisible
Gets or sets the IsVisible property. This observable property.
Declaration
public bool IsVisible { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
ValidationMessage
Gets or sets the ValidationMessage property. This observable property. NOTE: this class does not do any validation logic on its own. It is up to the consumer to set this value.
Declaration
public string ValidationMessage { get; set; }
Property Value
| Type | Description |
|---|---|
| string |
Methods
| Edit this page View SourceGetByValue(ObservableCollection<ISelectableItem>, string)
Declaration
protected ISelectableItem? GetByValue(ObservableCollection<ISelectableItem> values, string value)
Parameters
| Type | Name | Description |
|---|---|---|
| ObservableCollection<ISelectableItem> | values | |
| string | value |
Returns
| Type | Description |
|---|---|
| ISelectableItem |
Initialize(IEnumerable<ISelectableItem>)
Initializes the view model with the specified values. Values are copied into a new ObservableCollection.
Declaration
public override void Initialize(IEnumerable<ISelectableItem> values)
Parameters
| Type | Name | Description |
|---|---|---|
| IEnumerable<ISelectableItem> | values |
Overrides
| Edit this page View SourceSelectByText(string)
Searches the list of items for the specified text and selects the item if found. If not found, the selected item is set to null.
Declaration
public void SelectByText(string text)
Parameters
| Type | Name | Description |
|---|---|---|
| string | text |
SelectByValue(int)
Searches the list of items for the specified value and selects the item if found.
Declaration
public void SelectByValue(int value)
Parameters
| Type | Name | Description |
|---|---|---|
| int | value |
SelectByValue(string)
Searches the list of items for the specified value and selects the item if found.
Declaration
public virtual void SelectByValue(string value)
Parameters
| Type | Name | Description |
|---|---|---|
| string | value |