Control |
public abstract class ControlBase : IControlBase, IDisposable
The ControlBase type exposes the following members.
| Name | Description | |
|---|---|---|
| Kind | Kind of control. | |
| Name | Control name that is unique within the owning screen. Name of control must conform to the regex pattern [a-zA-Z0-9], as only letters and numbers are valid characters. | |
| Parent | Parent of the control. | |
| Screen | Screen the control resides in. | |
| TemplateId | Id used to find sibling controls within a template. All siblings will have the same id. Default value is null. |
| Name | Description | |
|---|---|---|
| AncestorsT | Get ancestor controls that implement generic control interface defined by T. | |
| GetPropertyT(String) | ||
| GetPropertyT(Object, String) | FOR SCRIPT USE ONLY: Get property of a ControlBase object. | |
| HasProperty | FOR SCRIPT USE ONLY: Check if object is a ControlBase with specified property. | |
| SetProperty(Object, String) | ||
| SetProperty(Object, String, Object, UpdateBehavior) | FOR SCRIPT USE ONLY: Set property of a ControlBase object. | |
| TryGetPropertyT | FOR SCRIPT USE ONLY: Try to get a property from ControlBase object. | |
| TrySetProperty | FOR SCRIPT USE ONLY: Try to set property of ControlBase object. |
Since all controls inherit from the BaseControl class, We can use the following static methods to get/set properties without casting to a specific control type.
Check if control has property.
object sender; // control bool hasHeight = ControlBase.HasProperty(sender, "Height");
Get property of control. NOTE: exception will be thrown if control does not have specified property.
object sender; // control int height = ControlBase.GetProperty<int>(sender, "Height");
Set property of control. NOTE: exception will be thrown if control cannot set specified property.
object sender; // control ControlBase.SetProperty(sender, "Height", 100);
Try to get property of control. NOTE: no exceptions will be thrown.
object sender; // control int height; bool result = ControlBase.TryGetProperty(sender, "Height", out height);
Try to set property of control. NOTE: no exceptions will be thrown.
object sender; // control int height = 100; bool result = ControlBase.TrySetProperty(sender, "Height", height);