Description
The ApplyCascading
method is a public instance method of the BaseStyles
class in the Sandbox.UI
namespace. This method is used to apply cascading styles from a parent BaseStyles
object to the current instance. Cascading styles allow for the inheritance of style properties from a parent style object, ensuring that the child object maintains consistency with its parent unless explicitly overridden.
Usage
To use the ApplyCascading
method, you need to have an instance of BaseStyles
that you want to apply cascading styles to. You will also need a parent BaseStyles
instance from which the styles will be inherited. Call the method on the child instance, passing the parent instance as a parameter.
Example
// Create a parent BaseStyles instance
BaseStyles parentStyles = new BaseStyles();
parentStyles.Width = new Length(100, LengthUnit.Percent);
parentStyles.BackgroundColor = Color.Red;
// Create a child BaseStyles instance
BaseStyles childStyles = new BaseStyles();
// Apply cascading styles from parent to child
childStyles.ApplyCascading(parentStyles);
// Now childStyles will inherit Width and BackgroundColor from parentStyles unless overridden