It doesn't seem like binding to StartValue / EndValue for both Scales and multiple Ranges really works. I dont see them having any effect. I have a scenario where the bounds of the gauge need to change dynamically - basically the viewmodel tracks the min and max values seen and I want the extents of the gauge to track these, so that the needle is always in the middle. If I bind to StartValue / EndValue nothing happens when I change the properties in my viewmodel.
I have other properties bound (StartValue / EndValue on a single range when the scale has fixed start/end seems to work) so it isn't a vm problem.
If I hook my view up to the propertychanged event of my viewmodel directly, I'm able to set startvalue/endvalue on the scale and 2nd range just fine, but this is ugly and not MVVM. I saw a prior thread from 2013 relating to the winrt controls, so maybe there's something similar going on here.
_radialGauge =
new SfCircularGauge
{
GaugeType = GaugeType.North
};
_scale =
new Scale
{
StartValue = 0,
StartAngle = 200,
SweepAngle = 140,
EndValue = 20, //DefaultAutoMax, //20,
ShowRim = false,
MajorTickSettings =
new TickSettings
{
Color = Color.FromRgba(128, 128, 128, 128),
Length = 200,
Offset = 0.08
},
MinorTicksPerInterval = 1,
MinorTickSettings =
new TickSettings
{
Color = Color.FromRgba(200, 200, 200, 128),
Length = 200,
Offset = 0.08,
},
Interval = 1.0,
//NumberOfDecimalDigits = 3,
LabelColor = CurrentTheme.ColorScheme.Gray50,
LabelOffset = 0,
LabelFontSize = 20, //known issue - this has no effect until next update
};
//_scale.SetBinding(Syncfusion.SfGauge.XForms.Scale.StartValueProperty, "RangeStart");
//_scale.SetBinding(Syncfusion.SfGauge.XForms.Scale.EndValueProperty, "RangeEnd");
//_scale.SetBinding(Syncfusion.SfGauge.XForms.Scale.IntervalProperty, "RangeInterval");
var pointer =
new NeedlePointer
{
Color = Color.FromRgb(228, 56, 130),
KnobColor = this.BackgroundColor,
KnobRadius = 400,
LengthFactor = 0.98,
EnableAnimation = false
};
pointer.SetBinding(NeedlePointer.ValueProperty, "Current");
_scale.Pointers.Add(pointer);
_backRange =
new Range
{
Color = Color.FromRgb(239, 227, 211),
Thickness = 220,
Offset = 0.05,
StartValue = 0,// scale.StartValue,
EndValue = _scale.EndValue//DefaultAutoMax,// scale.EndValue
};
//_backRange.SetBinding(Range.StartValueProperty, "RangeStart");
//_backRange.SetBinding(Range.EndValueProperty, "RangeEnd");
_scale.Ranges.Add(_backRange);
var range =
new Range
{
Color = Color.FromRgb(178, 216, 239),
Thickness = 220,
Offset = 0.05
};
range.SetBinding(Range.StartValueProperty, "Minimum");
range.SetBinding(Range.EndValueProperty, "Maximum");
_scale.Ranges.Add(range);
_radialGauge.Scales.Add(_scale);