This topic demonstrates how to add a Xamarin control to your app using XAML. This is done in three steps:
Step 1: Add a new Content Page
Step 2: Add the Control
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:c1="clr-namespace:C1.Xamarin.Forms.Gauge;assembly=C1.Xamarin.Forms.Gauge"> </ContentPage> |
<StackLayout></StackLayout>
tags.
The following code shows how to initialize a Gauge control.
XAML |
Copy Code
|
---|---|
<StackLayout> <c1:C1LinearGauge Value="35" Min="0" Max="100" Thickness="0.1" HeightRequest="50" WidthRequest="50" PointerColor="Blue" Direction="Right"> <c1:C1LinearGauge.Ranges> <c1:GaugeRange Min="0" Max="40" Color="Red"/> <c1:GaugeRange Min="40" Max="80" Color="Yellow"/> <c1:GaugeRange Min="80" Max="100" Color="Green"/> </c1:C1LinearGauge.Ranges> </c1:C1LinearGauge> </StackLayout> |
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(); } |
C# |
Copy Code
|
---|---|
C1.Xamarin.Forms.Gauge.Platform.iOS.C1GaugeRenderer.Init(); |
C# |
Copy Code
|
---|---|
C1.Xamarin.Forms.Gauge.Platform.UWP.C1GaugeRenderer.Init(); |