Xuni User Guide > Xuni Controls > Gauge > Quick Start: Add and Configure > BulletGraph Quick Start |
This section describes how to add a BulletGraph control to your portable or shared app and set its value. For information on how to add Xuni components in C# or XAML, see Adding Xuni Components using C# or Adding Xuni Components using XAML.
This topic comprises of three steps:
The following image shows how the BulletGraph appears, after completing the steps above.
The Value
property denotes the value of the Gauge. Multiple ranges can be added to a single Gauge and the position of the range is defined by the Min
and Max
properties of the range. If you set the Gauge's IsReadOnly
property to false, then the user is be able to edit the value by tapping on the Gauge.
Note: XuniBulletGraph.Origin property can be used to change the origin of the BulletGraph pointer. By default, the Origin is set to 0. |
Complete the following steps to initialize a BulletGraph control in C# or in XAML.
QuickStart.cs
) to your Portable / Shared project and include Xuni Gauge and Xamarin references as shown below.
C# |
Copy Code |
---|---|
using Xuni.Xamarin.Gauge; using Xamarin.Forms; |
GetBulletGraph()
(or GetRadialGauge()
/ GetBulletGraph()
).
C# |
Copy Code |
---|---|
public static XuniBulletGraph GetBulletGraph() { //Instantiate BulletGraph and set its properties XuniBulletGraph gauge = new XuniBulletGraph(); gauge.Value = 80; gauge.HeightRequest = 25; gauge.WidthRequest = 50; gauge.Min = 0; gauge.Max = 100; gauge.Thickness = 0.1; gauge.Direction =LinearGaugeDirection.Right; gauge.PointerColor = Color.Black; //Set its Good Bad and Target gauge.Good = 100; gauge.GoodRangeColor = Color.FromHex("#CCCCCC"); gauge.Bad = 50; gauge.BadRangeColor = Color.FromHex("#666666"); gauge.Target = 75; gauge.TargetColor = Color.Black; return gauge; } |
QuickStart.xaml
) to your Portable or Shared project and modify the <ContentPage>
tag to include Xuni reference as shown below.
XAML |
Copy Code |
---|---|
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="Appl.QuickStart" xmlns:xuni="clr-namespace:Xuni.Xamarin.Gauge;assembly=Xuni.Xamarin.Gauge"> |
<ContentPage></ContentPage>
tags and inside the <StackLayout></StackLayout>
tags, as shown below:
XAML |
Copy Code |
---|---|
<StackLayout> <xuni:XuniBulletGraph Value="80" Min="0" Max="100" HeightRequest="50" WidthRequest="50" Thickness="0.1" Good="100" GoodRangeColor="#CCCCCC" Bad="50" BadRangeColor="#666666" Target="75" TargetColor="Black" PointerColor="Black" Direction="Right"> </xuni:XuniBulletGraph> </StackLayout> |
App.cs
to open it.
App()
, set a new ContentPage
as the MainPage
and assign the control to the ContentPage
's Content
by invoking the method GetBulletGraph()
defined in the previous procedure, Step 1: Add a BulletGraph Control.
The following code shows the class constructor App()
after completing steps above.
C# |
Copy Code |
---|---|
public App() { // The root page of your application MainPage = new ContentPage { Content = QuickStart.GetBulletGraph() }; } |
App()
, set the Forms XAML Page QuickStart
as the MainPage
.
The following code shows the class constructor App()
, after completing this step.
C# |
Copy Code |
---|---|
public App() { // The root page of your application MainPage = new QuickStart(); } |
AppDelegate.cs
inside YourAppName.iOS project, to open it.
FinishedLaunching()
method.
C# |
Copy Code |
---|---|
Xuni.Xamarin.Gauge.Platform.iOS.Forms.Init(); |
MainPage.xml
.
MainPage.xml.cs
to open it.
C# |
Copy Code |
---|---|
Xuni.Xamarin.Gauge.Platform.WinPhone.GaugeRenderer.Init(); |