I don't know of a way to bind to a simple value, but it is defintely possible to bind to a property, and it will work particularly well if the class the property belongs to implements INotifyPropertyChanged.
You cna use the DataBindings property of your scale object to do this.
This is a snippet that has been slightly modified from the code from LinearGuage class help.
class Test : INotifyPropertyChanged {
private int _MyValue;
public int MyValue {
get { return _MyValue; }
set { _MyValue = value; RaisePropertyChanged("MyValye"); }
}
#region INotifyPropertyChanged Members
public event PropertyChangedEventHandler PropertyChanged;
#endregion
private void RaisePropertyChanged(string name)
{
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(name));
}
}
}
GaugeControl gc = new GaugeControl();
LinearGauge linearGauge = gc.AddLinearGauge();
linearGauge.AddDefaultElements();
LinearScaleComponent scale = linearGauge.Scales[0];
Test myObject = new Test();
// scale.Value = 20;
// Instead of assigning a value, let's set up some data binding isntead.
scale.DataBindings.Add("Value", myObject, "MyValue", false, DataSourceUpdateMode.OnPropertyChanged);
// This will now update the guage
myObject.MyValue = 50;
... rest of code