Add custom properties to displays.
How-to Guides → Solution Examples → Feature Examples → User Interactions Examples → Displays Custom Properties Example
Display Custom Properties are local variables created for a specific Display. They can be accessed in CodeBehind and in the Display itself.
Custom properties can also be linked to Tags by setting the Property Name as @Tag.<TagName>, where <TagName> is a valid name in Unified Namespace → Tags.
The properties added to your display are stored as an array. They are accessed through an index. The index ordination depends on the order the properties were created.
E.g.:
@Display.<PageName>.CustomProperties[index];
This property can be used as an alternative to using tags in any logic.
An advantage is the possibility of decreasing the total communication points while maintaining the same project functionalities. This can be very useful depending on your license type.
On the other hand, the logic programmed with the CustomProperties is only valid for a specific Display, meaning you cannot retain the data from one Page to use in another one.
Methods Available in Runtime
SetCustomPropertyValue(string propertyName, object propertyValue)
Sets custom property.
If the property does not already exist, it will be created as a new Property.
- propertyName: Property Name. If the name starts with the
@symbol and the rest of the string is a valid tag name, the property is a reference to the Tag. - propertyValue: Property value
- No return value (always returns 0).
@Display.MainPage.SetCustomPropertyValue("@Tag.Integer1", 50);
SetCustomProperties(string str, string sep)
- Sets several custom properties at the same time.
- str: String containing custom properties separated by
sep. - sep: Separator between each custom property.
@Display.MainPage.SetCustomProperties("p1=10;p2=20", ";");
GetCustomPropertiesAsString(string sep)
- Gets all custom properties.
- Default separator is
,. - Returns a string.
string msg = @Display.About.GetCustomPropertiesAsString(",");
GetCustomPropertyValue(string propertyName, string defaultValue)
- Gets value of a custom property by name.
- propertyName: Property Name.
- defaultValue: Default value returned if the property cannot be found.
- Returns the property value.
string propValue = @Display.MainPage.GetCustomPropertyValue("p1", "-1").ToString();
RemoveAllCustomProperties()
- Removes all custom properties.
- No return value.
@Display.LogOn.RemoveAllCustomProperties();
Note
If a Tag's Custom Property is removed, the Tag will retain the old property as its current value.
In this section...