Class ViewState
Definition
Namespace: StardewUI.Framework.Behaviors
Assembly: StardewUI.dll  
View state manager based on the view's runtime descriptor and defaults.
Inheritance
Object ⇦ ViewState
Implements
IViewState
Members
Constructors
| Name | Description | 
|---|---|
| ViewState(IViewDescriptor, IViewDefaults, ViewState) | View state manager based on the view's runtime descriptor and defaults. | 
Methods
| Name | Description | 
|---|---|
| GetDefaultValue<T>(string) | Retrieves the default value for a given property. | 
| GetFlag<T>(string) | Gets the current value of a flag, if one is set. | 
| GetOrAddProperty<T>(string) | Gets the override states for the specified property, creating a new one if it does not already exist. | 
| GetProperty<T>(string) | Gets the override states for the specified property, if any exist. | 
| SetFlag(string, Object) | Sets an arbitrary flag that other behaviors can read and/or be notified about. | 
| Write(IView) | Writes the active overrides to the target view. | 
Events
| Name | Description | 
|---|---|
| FlagChanged | Event raised when a flag changes, i.e. as the outcome of SetFlag(string, Object). | 
Details
Constructors
ViewState(IViewDescriptor, IViewDefaults, ViewState)
View state manager based on the view's runtime descriptor and defaults.
public ViewState(StardewUI.Framework.Descriptors.IViewDescriptor viewDescriptor, StardewUI.Framework.Descriptors.IViewDefaults viewDefaults, StardewUI.Framework.Behaviors.ViewState previousState);
Parameters
viewDescriptor   IViewDescriptor
Descriptor for the managed view type, providing property accessors.
viewDefaults   IViewDefaults
Default values for the managed view type.
previousState   ViewState
The previous state from which to restore the transient property values.
Methods
GetDefaultValue<T>(string)
Retrieves the default value for a given property.
Parameters
propertyName   string
The property name.
Returns
T
The default value for the specified propertyName.
Remarks
The default value is the value that will be used when there are no states for that property, i.e. when GetProperty<T>(string) returns null for the specified propertyName or when the property's states are empty. 
Defaults are real-time; if the property is linked via data binding, then the default value is the value that is currently bound.
GetFlag<T>(string)
Gets the current value of a flag, if one is set.
Parameters
name   string
The flag name.
Returns
T
The flag value, or the default of T if not set.
GetOrAddProperty<T>(string)
Gets the override states for the specified property, creating a new one if it does not already exist.
Parameters
propertyName   string
The property name.
Returns
The state overrides for the specified property on the current view.
GetProperty<T>(string)
Gets the override states for the specified property, if any exist.
Parameters
propertyName   string
The property name.
Returns
The state overrides for the specified property, or null if none have been added.
SetFlag(string, Object)
Sets an arbitrary flag that other behaviors can read and/or be notified about.
Parameters
name   string
The flag name.
value   Object
The flag value, or null to unset.
Write(IView)
Writes the active overrides to the target view.
Parameters
view   IView
The view that should receive the state/overrides.
Events
FlagChanged
Event raised when a flag changes, i.e. as the outcome of SetFlag(string, Object).