Xuni User Guide > Getting Started with Xuni > Adding Xuni Components using XAML |
This topic demonstrates how to add a Xuni control to your app using XAML. This is done in three steps:
Step 1: Add a new Forms XAML Page
Page1.xaml
) and click OK. A new XAML page is added to your project. Step 2: Add the Control
Page1.xaml
to open it.
<ContentPage>
tag to include Xuni references 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="YourAppName.Page1" xmlns:xuni="clr-namespace:Xuni.Xamarin.Gauge;assembly=Xuni.Xamarin.Gauge" > |
<ContentPage></ContentPage>
tags and inside the <StackLayout></StackLayout>
tags.
The following code shows how to initialize a Gauge control.
XAML |
Copy Code |
---|---|
<StackLayout> <xuni:XuniLinearGauge Value="35" Min="0" Max="100" Thickness="0.1" HeightRequest="50" WidthRequest="50" PointerColor="Blue" Direction="Right"> <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> </StackLayout> |
App.cs
to open it.
App()
, set the Forms XAML Page Page1
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 Page1(); } |
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(); |