Show / Hide Table of Contents

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.

Inheritance
object
ViewModelBase
ViewModelField<T>
Implements
INotifyPropertyChanged
IVisibleField
Inherited Members
ViewModelBase.RaisePropertyChanged(string)
ViewModelBase.PropertyChanged
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
object.ReferenceEquals(object, object)
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 Source

ViewModelField()

Declaration
public ViewModelField()
| Edit this page View Source

ViewModelField(T)

Declaration
public ViewModelField(T initialValue)
Parameters
Type Name Description
T initialValue

Properties

| Edit this page View Source

IsEnabled

Should the field be enabled on the form?

Declaration
public bool IsEnabled { get; set; }
Property Value
Type Description
bool
| Edit this page View Source

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
| Edit this page View Source

IsVisible

Should the field be visible on the form?

Declaration
public bool IsVisible { get; set; }
Property Value
Type Description
bool
| Edit this page View Source

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
| Edit this page View Source

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 Source

RaiseOnValueChanged()

Raises the OnValueChanged event.

Declaration
public virtual void RaiseOnValueChanged()
| Edit this page View Source

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
object.ToString()
Exceptions
Type Condition
InvalidOperationException

Events

| Edit this page View Source

OnValueChanged

Event raised when the Value property changes on this field.

Declaration
public event EventHandler? OnValueChanged
Event Type
Type Description
EventHandler

Implements

INotifyPropertyChanged
IVisibleField
  • Edit this page
  • View Source
In this article
Back to top Copyright © www.benday.com | info@benday.com