Description
The Percentage
field of the LengthUnit
enum represents a length value that is a percentage of the parent's length. This is typically used in UI layout calculations where the size of an element is determined relative to its parent element's dimensions. The percentage value ranges from 0 to 100.
Usage
Use LengthUnit.Percentage
when you want to specify a length as a percentage of the parent element's size. This is useful for creating responsive designs where elements need to scale proportionally with their parent containers.
Example
// Example of using LengthUnit.Percentage in a UI component
public class MyPanel : Panel
{
public MyPanel()
{
// Set the width of the panel to 50% of its parent's width
Style.Width = Length.Percent(50);
// Set the height of the panel to 75% of its parent's height
Style.Height = Length.Percent(75);
}
}