Behaviors
- 3 minutes to read
Attach a Behavior to target controls and components to template them in a specific manner. For instance, a Clock Behavior turns a LabelControl or a digital gauge into a clock.
Target controls do not necessarily have common ancestors, so Behaviors are implemented as standalone objects.
Attach a Behavior to a Control
Open the Visual Studio’s Toolbox window, locate the Behavior Manager component and drop it onto the form. Invoke the component smart tag and click “Edit Behaviors”.
Once you click the link, the Collection Editor dialog pops up. You can create new Behaviors and attach them to controls by setting their Target properties using this dialog.
Most controls that support Behaviors display the “Add Behaviors…” link within their smart tags. Clicking this link automatically adds the Behavior Manager component and opens its Collection Editor dialog. However, you can create and modify Behaviors assigned to this control only.
Behaviors can also be attached in code using the Behavior Manager’s Attach method and utilizing lambda expressions to set the required Behavior options.
using DevExpress.Utils.Behaviors.Common;
behaviorManager1.Attach<OpenFolderBehavior>(beOpenFolder, behavior => {
behavior.Properties.IconSize = FileIconSize.Small;
behavior.Properties.InvalidPathImage = DevExpress.Images.ImageResourceCache.Default.GetImage("images/actions/close_16x16.png");
behavior.Properties.ShowIcon = true;
});
Available Behaviors
The table below enumerates all supported Behaviors and controls to which Behaviors you can attach them. You can also submit Support Center tickets to request new Behaviors.
Behavior Name | Description | Target Controls |
---|---|---|
Checks the display text of the target control and if this text is a path to an existing file or folder, adds its icon to the control. | ||
Same as FileIconBehavior. Additionally, if the target control allows end-users to edit display text at runtime, it also provides the auto-complete feature. | ||
Attach these behaviors to a ButtonEdit control to instantly transform it into an editor that allows end-users to choose a file or a folder from the local storage. The editor displays an icon and a caption of the selected file (folder). | ||
This behavior can be attached to a form to restore its last known position and size at runtime. |
controls that implement the ISupportXtraSerializer interface | |
Turns standard and DevExpress forms into sticky windows that can snap to other windows and screen edges. |
standard forms and their descendants | |
With this behavior attached, items that have no custom icons display temporary fake images. | ||
A control with this behavior displays current system’s date and time. The behavior provides the ability to customize both date and time data portions separately. | ||
Indicates whether or not the specific system key (Caps Lock, Num Lock, Scroll Lock) is currently pressed. | ||
Forces a PictureEdit control to cycle through a collection of images instead of constantly displaying the same one. | ||
Adds support for drag-and-drop operations between controls. | ||
Allows users to pick colors from the screen using the Magnifier tool. | All ColorEdit descendants |