Xuni User Guide > Xuni Controls > Gauge > Features > Range |
You can add multiple ranges to a single Gauge. Each range denotes a region or a state which can help the user identify the state of the Gauge's value. Every range has its Min
and Max
properties that specify the range's position on the Gauge, as well as Color
and Thickness
properties that define the range's appearance.
The following code examples demonstrate how to add ranges to a Gauge and set their properties in C# and XAML.
Create new instances of type GaugeRange
, set their properties and add the newly created ranges to the LinearGauge (or RadialGauge/BulletGraph).
C# |
Copy Code |
---|---|
//Create Ranges GaugeRange low = new GaugeRange(); GaugeRange med = new GaugeRange(); GaugeRange high = new GaugeRange(); //Customize Ranges low.Color = Color.Red; low.Min = 0; low.Max = 40; med.Color = Color.Yellow; med.Min = 40; med.Max = 80; high.Color = Color.Green; high.Min = 80; high.Max = 100; //Add Ranges to Gauge gauge.Ranges.Add(low); gauge.Ranges.Add(med); gauge.Ranges.Add(high); |
Add the markup for ranges between the opening and closing tags of the control (<xuni:XuniLinearGauge></xuni:XuniLinearGauge>
in this example), to create new ranges and add them to the LinearGauge (or RadialGauge/BulletGraph).
HTML |
Copy Code |
---|---|
<xuni:XuniLinearGauge Value="35" Min="0" Max="100" Thickness="0.1" HeightRequest="50" WidthRequest="50"> <xuni:XuniLinearGauge.Ranges> <xuni:GaugeRange Min="0" Max="40" Color="Red"/> <xuni:GaugeRange Min="40" Max="80" Color="Yellow"/> <xuni:GaugeRange Min="80" Max="100" Color="Green"/> </xuni:XuniLinearGauge.Ranges> </xuni:XuniLinearGauge> |