Class FlagStateBehavior<TValue>
Definition
Namespace: StardewUI.Framework.Behaviors
Assembly: StardewUI.dll
Behavior that applies a property override when a named view state flag is detected.
Type Parameters
TValue
Value type for the overridden property.
Inheritance
Object ⇦ ViewBehavior<TView, TData> ⇦ FlagStateBehavior<TValue>
Remarks
The flag is generally added or removed by ConditionalFlagBehavior as part of a two-step approach to creating conditional attributes.
Members
Constructors
Name | Description |
---|---|
FlagStateBehavior<TValue>(string, string) | Behavior that applies a property override when a named view state flag is detected. |
Properties
Name | Description |
---|---|
Data | The assigned or bound data. (Inherited from ViewBehavior<TView, TData>) |
View | The currently-attached view. (Inherited from ViewBehavior<TView, TData>) |
ViewState | State overrides for the View. (Inherited from ViewBehavior<TView, TData>) |
Methods
Name | Description |
---|---|
CanUpdate() | Checks whether the behavior is allowed to Update(TimeSpan). (Inherited from ViewBehavior<TView, TData>) |
Dispose() | (Inherited from ViewBehavior<TView, TData>) |
Initialize(BehaviorTarget) | Initializes the target (view, state overrides, etc.) for the behavior. (Inherited from ViewBehavior<TView, TData>) |
OnAttached() | Runs after the behavior is attached to a target. (Overrides ViewBehavior<TView, TData>.OnAttached()) |
OnDetached(IView) | Runs when the behavior is detached from a target. (Overrides ViewBehavior<TView, TData>.OnDetached(IView)) |
OnDispose() | Runs when the behavior is being disposed. (Inherited from ViewBehavior<TView, TData>) |
OnNewData(TValue) | (Overrides ViewBehavior<TView, TData>.OnNewData(TData)) |
PreUpdate(TimeSpan) | Runs on every update tick, before any bindings or views update. (Inherited from ViewBehavior<TView, TData>) |
Update(TimeSpan) | Runs on every update tick. (Inherited from ViewBehavior<TView, TData>) |
Details
Constructors
FlagStateBehavior<TValue>(string, string)
Behavior that applies a property override when a named view state flag is detected.
Parameters
flagName
string
Name of the flag to watch.
propertyName
string
Name of the overridden property.
Remarks
The flag is generally added or removed by ConditionalFlagBehavior as part of a two-step approach to creating conditional attributes.
Methods
OnAttached()
Runs after the behavior is attached to a target.
Remarks
Setup code should go in this method to ensure that the values of View and ViewState are actually assigned. If code runs in the behavior's constructor, these are not guaranteed to be populated.
OnDetached(IView)
Runs when the behavior is detached from a target.
Parameters
view
IView
The view that was previously attached.
Remarks
Behaviors may receive new views as part of a "rebind", if the old view is destroyed and recreated, for example as the result of a conditional binding changing states.
OnDetached
is always immediately followed by OnAttached(). A behavior cannot remain in a detached state; however, overriding this method gives behaviors the opportunity to clean up state from the old view (e.g. remove event handlers) before the new one is attached.
Also runs when the behavior is disposed, so detach logic does not need to be duplicated in OnDispose().
OnNewData(TValue)
Parameters
previousData
TValue