this.BindingContext = pressureMeasurementData;
Grid grid = new Grid {
VerticalOptions = LayoutOptions.FillAndExpand,
RowDefinitions =
{
new RowDefinition { Height = GridLength.Auto },
new RowDefinition { Height = GridLength.Auto },
new RowDefinition { Height = GridLength.Auto },
new RowDefinition { Height = GridLength.Auto },
new RowDefinition { Height = GridLength.Auto }
},
ColumnDefinitions =
{
new ColumnDefinition { Width = GridLength.Auto },
new ColumnDefinition { Width = GridLength.Auto }
}
};
grid.Children.Add(new Label {
Text = "Pressure"
}, 1, 1);
grid.Children.Add(new Label {
Text = "Min"
}, 1, 2);
grid.Children.Add(new Label {
Text = "Max"
}, 1, 3);
grid.Children.Add(new Label {
Text = "Unit"
}, 1, 4);
Label pressureLabel = new Label();
pressureLabel.SetBinding(Label.TextProperty, "Pressure");
grid.Children.Add(pressureLabel, 2, 1);
Label minLabel = new Label() { Text = "Min", TextColor= Color.Green };
minLabel.SetBinding(Label.TextProperty, "Min");
grid.Children.Add(minLabel, 2, 2);
Label maxLabel = new Label() { Text = "Max", TextColor = Color.Red };
maxLabel.SetBinding(Label.TextProperty, "Max");
grid.Children.Add(maxLabel, 2, 3);
grid.Children.Add(new Label {
Text = "bar"
}, 2, 4);
SfCircularGauge circularGauge = new SfCircularGauge();
circularGauge.HorizontalOptions = LayoutOptions.CenterAndExpand;
Scale scale = new Scale();
scale.StartValue = 0;
scale.EndValue = 100;
scale.Interval = 10;
scale.StartAngle = 135;
scale.SweepAngle = 270;
scale.RimThickness = 10;
scale.RimColor = Color.Gray;
scale.MinorTicksPerInterval = 4;
scale.LabelColor = Color.Black;
scale.LabelFontSize = 15;
scale.MajorTickSettings.Color = Color.Black;
scale.MinorTickSettings.Color = Color.Black;
scale.LabelOffset = 0.1;
NeedlePointer needlePointer = new NeedlePointer();
needlePointer.Color = Color.Black;
needlePointer.KnobColor = Color.Black;
needlePointer.Thickness = 2;
needlePointer.KnobRadius = 10;
needlePointer.LengthFactor = 0.7;
needlePointer.SetBinding(NeedlePointer.ValueProperty, "Pressure");
scale.Pointers.Add(needlePointer);
NeedlePointer minPointer = new NeedlePointer();
minPointer.Color = Color.Green;
minPointer.KnobColor = Color.Black;
minPointer.Thickness = 1;
minPointer.KnobRadius = 10;
minPointer.LengthFactor = 0.6;
minPointer.SetBinding(NeedlePointer.ValueProperty, "Min");
scale.Pointers.Add(minPointer);
NeedlePointer maxPointer = new NeedlePointer();
maxPointer.Color = Color.Red;
maxPointer.KnobColor = Color.Black;
maxPointer.Thickness = 1;
maxPointer.KnobRadius = 10;
maxPointer.LengthFactor = 0.6;
maxPointer.SetBinding(NeedlePointer.ValueProperty, "Max");
scale.Pointers.Add(maxPointer);
circularGauge.Scales.Add(scale);
grid.Children.Add(circularGauge, 1, 5);
Grid.SetColumnSpan(circularGauge,2);
Content = grid;