Action Properties
Action properties represent abstract metadata about the actions that the user can perform on your screen, which includes the following.
- Action name, which should be unique within the context it's used in and serves as a resource key.
- Localized action text that is displayed to the user on the UI.
- Enabled indicator that tells if the action is currently enabled.
- Visibility of the action indicates whether or not the action is currently visible.
Action properties can be bound to various action controls on the UI, such as buttons, menu options, etc. Any changes in the action's enabled state or visibility would be automatically reflected in the bound UI control, which allows you to implement the logic for enabling, disabling and hiding your actions in a UI-agnostic way.
Action properties do not perform the actual action, but only manage the state of that action. You still need to set the proper handler on the bound UI control, which would invoke your logic for that action.
The ActionProperty
class that is used for action properties extends BaseProperty
to support the state management and property change events. However, it does not carry any data, nor store any value, so it doesn't extend the DataProperty
class.
Constructing actions
Action properties can be defined either as part of a parent data object or as standalone actions that you can store on your view model.
Data object actions
When an action logically belongs to a certain data object, then you can construct it and store it inside that data object, and pass that object as a parent along with the unique action name, similar to the way you construct regular data properties. For example, if your data object has a RecalculateAction, then you can construct it as follows.
protected override void Initialize()
{
RecalculateAction = new ActionProperty(this, Messages.Action_Recalculate);
}
Just like with data properties, actions created with a parent object will be registered within that object. This allows the data object to manage these actions and recalculate their state as needed.
Data objects already define and track the state of some standard actions, such as Save and Delete, which you can then bind to the corresponding buttons on your screen, as needed.