Skip to content

Interface IViewState

Definition

Namespace: StardewUI.Framework.Behaviors
Assembly: StardewUI.dll

Provides access to all state-based overrides associated with a view.

public interface IViewState

Members

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

Methods

GetDefaultValue<T>(string)

Retrieves the default value for a given property.

T GetDefaultValue<T>(string propertyName);
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.

T GetFlag<T>(string name);
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.

StardewUI.Framework.Behaviors.IPropertyStates<T> GetOrAddProperty<T>(string propertyName);
Parameters

propertyName   string
The property name.

Returns

IPropertyStates<T>

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.

StardewUI.Framework.Behaviors.IPropertyStates<T> GetProperty<T>(string propertyName);
Parameters

propertyName   string
The property name.

Returns

IPropertyStates<T>

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.

void SetFlag(string name, System.Object value);
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.

void Write(StardewUI.IView 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).

event EventHandler<StardewUI.Framework.Behaviors.FlagEventArgs>? FlagChanged;
Event Type

EventHandler<FlagEventArgs>