Class ViewModelField<T>
View model class that represents a field on a form. For example, "FirstName", "LastName", "Age", or "BirthDate". It provides properties for validation, visibility, and enabled. If you're using Benday.Presentation.Controls, those field controls will bind to the properties on this class with a single, simple binding expression.
Inherited Members
Namespace: Benday.Presentation
Assembly: Benday.Presentation.dll
Syntax
public class ViewModelField<T> : ViewModelBase, INotifyPropertyChanged, IVisibleField
Type Parameters
Name | Description |
---|---|
T | Data type being wrapped by this field. Typically types like int, string, DateTime, etc. |
Constructors
| Edit this page View SourceViewModelField()
Declaration
public ViewModelField()
ViewModelField(T)
Declaration
public ViewModelField(T initialValue)
Parameters
Type | Name | Description |
---|---|---|
T | initialValue |
Properties
| Edit this page View SourceIsEnabled
Should the field be enabled on the form?
Declaration
public bool IsEnabled { get; set; }
Property Value
Type | Description |
---|---|
bool |
IsValid
Represents the validation status of this field. If IsValid is false, then ValidationMessage should contain a message. NOTE: this class does not perform any validation logic on its own. It is up to the consumer to set this value and if necessary the ValidationMessage value.
Declaration
public bool IsValid { get; set; }
Property Value
Type | Description |
---|---|
bool |
IsVisible
Should the field be visible on the form?
Declaration
public bool IsVisible { get; set; }
Property Value
Type | Description |
---|---|
bool |
ValidationMessage
Gets or sets the ValidationMessage property. This observable property. This is intended to be displayed when IsValid is false. 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 |
Value
Gets or sets the Value of this field. This observable property.
Declaration
public T Value { get; set; }
Property Value
Type | Description |
---|---|
T |
Methods
| Edit this page View SourceRaiseOnValueChanged()
Raises the OnValueChanged event.
Declaration
public virtual void RaiseOnValueChanged()
ToString()
Returns the Value property of this field as a string. If Value is null, returns String.Empty.
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
string |
Overrides
Exceptions
Type | Condition |
---|---|
InvalidOperationException |
Events
| Edit this page View SourceOnValueChanged
Event raised when the Value property changes on this field.
Declaration
public event EventHandler? OnValueChanged
Event Type
Type | Description |
---|---|
EventHandler |