- Home
- Forum
- Xamarin.Forms
- DigitalGauge not displayed
DigitalGauge not displayed
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection.Emit;
using System.Text;
using UIDesign.Model;
using Xamarin.Forms;
public class SensorValuesDetailPage : ContentPage {
public SensorValuesDetailPage(ObservableSensorClass sensor) {
this.Title = "Werte";
HorizontalOptions = LayoutOptions.StartAndExpand,
VerticalOptions = LayoutOptions.FillAndExpand
};
this.BindingContext = sensor;
Minimum = 0,
Maximum = 100,
Value = sensor.Value,
VerticalOptions = LayoutOptions.CenterAndExpand,
WidthRequest = 300
};
sensor.Value = e.NewValue;
};
Text = sensor.Value.ToString()
Scale scale = new Scale();
scale.StartValue = 0;
scale.EndValue = 100;
scale.Interval = 10;
scale.StartAngle = 135;
scale.SweepAngle = 270;
scale.RimThickness = 20;
scale.RimColor = Color.FromHex("#FB0101");
scale.MinorTicksPerInterval = 3;
needlePointer.Color = Color.White;
needlePointer.KnobColor = Color.White;
needlePointer.Thickness = 5;
needlePointer.KnobRadius = 20;
needlePointer.LengthFactor = 0.8;
needlePointer.SetBinding(NeedlePointer.ValueProperty, "Value");
scale.Pointers.Add(needlePointer);
rangePointer.Value = 60;
rangePointer.Color = Color.FromHex("#FFA9A9A9");
rangePointer.Thickness = 20;
rangePointer.SetBinding(RangePointer.ValueProperty, "Value");
scale.Pointers.Add(rangePointer);
stack.Children.Add(circularGauge);
digitalGauge1.CharacterStrokeColor = Color.FromRgb(20, 108, 237);
digitalGauge1.CharacterSpacing = 2;
digitalGauge1.CharacterWidth = 12;
digitalGauge1.SegmentStrokeWidth = 2;
digitalGauge1.CharacterType = CharacterType.EightCrossEightDotMatrix;
digitalGauge1.SetBinding(SfDigitalGauge.ValueProperty, "Value");
Label label = new Label {
Text = "Line1\nLine2\n",
FontSize = 20,
HorizontalOptions = LayoutOptions.CenterAndExpand
};
stack.Children.Add(label);
}
}
}
using Syncfusion.SfGauge.XForms;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection.Emit;
using System.Text;
using UIDesign.Model;
using Xamarin.Forms;
namespace UIDesign {
public class SensorValuesDetailPage : ContentPage {
public SensorValuesDetailPage(ObservableSensorClass sensor) {
this.Title = "Werte";
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 },
new RowDefinition { Height = GridLength.Auto }
},
ColumnDefinitions = {
new ColumnDefinition { Width = GridLength.Auto }
}
};
this.BindingContext = sensor;
Slider slider = new Slider {
Minimum = 0,
Maximum = 100,
Value = sensor.Value,
VerticalOptions = LayoutOptions.CenterAndExpand,
WidthRequest = 300
};
slider.ValueChanged += (sender, e) => {
sensor.Value = e.NewValue;
};
grid.Children.Add(slider, 1, 1);
Label valueLabel = new Label {
Text = sensor.Value.ToString()
};
valueLabel.SetBinding(Label.TextProperty, "Value");
grid.Children.Add(valueLabel, 1, 2);
SfCircularGauge circularGauge = new SfCircularGauge();
Scale scale = new Scale();
scale.StartValue = 0;
scale.EndValue = 100;
scale.Interval =10;
scale.StartAngle = 135;
scale.SweepAngle = 270;
scale.RimThickness = 20;
scale.RimColor = Color.FromHex("#FB0101");
scale.MinorTicksPerInterval = 3;
scale.LabelFontSize = 0.1;
NeedlePointer needlePointer = new NeedlePointer();
needlePointer.Color = Color.White;
needlePointer.KnobColor = Color.White;
needlePointer.Thickness = 5;
needlePointer.KnobRadius = 20;
needlePointer.LengthFactor = 0.8;
needlePointer.SetBinding(NeedlePointer.ValueProperty, "Value");
scale.Pointers.Add(needlePointer);
RangePointer rangePointer = new RangePointer();
rangePointer.Value = 60;
rangePointer.Color = Color.FromHex("#FFA9A9A9");
rangePointer.Thickness = 20;
rangePointer.SetBinding(RangePointer.ValueProperty, "Value");
scale.Pointers.Add(rangePointer);
circularGauge.Scales.Add(scale);
grid.Children.Add(circularGauge, 1, 3);
Label label = new Label {
Text = "Line1\nLine2\nLine3\nLine4\nLine5\nLine6\nLine7\nLine8\nLine9\nLine10\nLine11\nLine12\nLine13\nLine14\nLine15\nLine16\nLine17\nLine18\nLine19\nLine20\n",
FontSize = 20,
HorizontalOptions = LayoutOptions.CenterAndExpand
};
grid.Children.Add(label, 1, 4);
SfDigitalGauge digitalGauge1 = new SfDigitalGauge();
digitalGauge1.CharacterStrokeColor = Color.FromRgb(20, 108, 237);
digitalGauge1.CharacterHeight = 25;
digitalGauge1.CharacterSpacing = 2;
digitalGauge1.CharacterWidth = 12;
digitalGauge1.SegmentStrokeWidth = 2;
digitalGauge1.CharacterType = CharacterType.EightCrossEightDotMatrix;
digitalGauge1.SetBinding(SfDigitalGauge.ValueProperty, "Value");
grid.Children.Add(digitalGauge1, 1, 5);
SfDigitalGauge digitalGauge2 = new SfDigitalGauge();
digitalGauge2.CharacterStrokeColor = Color.FromRgb(20, 108, 237);
digitalGauge2.CharacterHeight = 25;
digitalGauge2.CharacterSpacing = 2;
digitalGauge2.CharacterWidth = 12;
digitalGauge2.SegmentStrokeWidth = 2;
digitalGauge2.CharacterType = CharacterType.EightCrossEightDotMatrix;
digitalGauge2.SetBinding(SfDigitalGauge.ValueProperty, "Value");
grid.Children.Add(digitalGauge2, 1, 6);
ScrollView scrollview = new ScrollView {
Padding = new Thickness(20)
};
StackLayout stack = new StackLayout {
HorizontalOptions = LayoutOptions.StartAndExpand,
VerticalOptions = LayoutOptions.Fill
};
stack.Children.Add(grid);
scrollview.Content = stack;
Content = scrollview;
}
}
}
We would like to inform that, the Label element’s content has occupied the maximum row span and left no space for DigitalGauge control. We have provided some additional rows definitions and we have specified height in ‘HeightRequest’ property for digital gauge control.
We have prepared a sample based on your code example which can be downloaded from the following link,
Link: http://www.syncfusion.com/downloads/support/forum/120976/ze/DigitalGaugeSample654218095.zip/
Please let us know if you need any further assistance on this.
Regards,
Hemalatha M.
Thanks for the update,
We are glad that your requirement has been achieved.
Please let us know if you have any query.
Regards,
Hemalatha M.
- 3 Replies
- 2 Participants
-
JB Jens Bohrmann
- Oct 30, 2015 01:18 PM UTC
- Nov 3, 2015 06:37 AM UTC