Api Sandbox UI Length
struct

Length

public sealed struct Length

A variable unit based length. ie, could be a percentage or a pixel length. This is commonly used to express the size of things in UI space, usually coming from style sheets.

Properties

Name Type Description
Auto static Length Quickly create a Length with Unit set to LengthUnit.Auto
Contain static Length Quickly create a Length with Unit set to LengthUnit.Contain
Cover static Length Quickly create a Length with Unit set to LengthUnit.Cover
Undefined static Length

Methods

Single GetPixels(Single dimension)

Convert to a pixel value. Use the dimension to work out percentage values.

Single GetPixels(Single dimension, Single contentSize)

Get the pixel size but also evaluate content size to support use Start, End, Center

static Length? Pixels(Single pixels)

Create a length in pixels

pixels — The amount of pixels for this length
returns — A new length
static Length? Percent(Single percent)

Create a length in percents

percent — The amount of percent for this (0-100)
returns — A new length
static Length? ViewHeight(Single percentage)

Create a length based on the view height

percentage — The amount of percent for this (0-100)
returns — A new length
static Length? ViewWidth(Single percentage)

Create a length based on the view width

percentage — The amount of percent for this (0-100)
returns — A new length
static Length? ViewMax(Single percentage)

Create a length based on the longest edge of the screen size

percentage — The amount of percent for this (0-100)
returns — A new length
static Length? ViewMin(Single percentage)

Create a length based on the shortest edge of the screen size

percentage — The amount of percent for this (0-100)
returns — A new length
static Length? Fraction(Single fraction)

Create a length in percents

fraction — The fraction of a percent (0 = 0%, 1 = 100%)
returns — A new length
static Length? Calc(String expression)

Create a length based on a css calc expression

static Length Rem(Single value)

Create a length based on the font size of the root element.

value — Value in rem
returns — A new length
static Length Em(Single value)

Create a length based on the font size of the current element.

value — Value in em
returns — A new length
static Length? Parse(String value)

Parse a length. This is used by the stylesheet parsing system.

value — A length represented by a string

Fields

Name Type Description
Value Single The meaning of the value is dependent on Unit.
Unit LengthUnit How to determine the final length. Commonly used with Pixel or Percentage.
Assembly: Sandbox.System Namespace: Sandbox.UI Full Name: Sandbox.UI.Length