in
Forums
Blogs
Files
Devexpress.Com
Client Center
Support Center
DevExpress Channel

How binding simple value to the gauge

Last post 10/28/2008 3:00 AM by Roman K (Developer Express). 9 replies.
Page 1 of 1 (10 items)
Sort Posts:
Previous Next
  • 7/26/2008 1:04 PM

    How binding simple value to the gauge

    Dear All

    How can bind a simple value (not DATASET or DATATABLE) for show in the gauge ? Confused

    Thanks !!

    RB

    Filed under:
  • 7/27/2008 11:58 AM In reply to

    • Pavel
    • Top 200 Contributor
    • Joined on 7/4/2007
    • Posts 55

    Re: How binding simple value to the gauge

    Can you do that with any nonwpf control i wonder? Hmm

    WPF HATER BLOG
    http://wpfhater.blogspot.com/
  • 7/28/2008 8:38 PM In reply to

    Re: How binding simple value to the gauge

    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

     

  • 7/29/2008 5:49 AM In reply to

    Re: How binding simple value to the gauge

     I have to say that I think I'm with you on this one...

    The guages look fantastic BUT perhaps what I want is some kind of dumbed down version (I'm sure a simplified interface could be added. When I add a guage I want it to behave like any other control:

    If I dock it to the window it expands or shrinks with that window (currently the guage control may change size but the guage contained in it don't.

    I love the way I can customize the look of the guage itself but in use I just want to set the range of values then change a .value property and the needle deflects, indicator changes etc. I am finding it quite hard work just to add a control that displays a value via a guage - in fact I haven't located where the equivalent of the .value property is I am assuming I need to reference something within the object model but the current help really doesn't appear to be very "helpful".

     

  • 7/29/2008 8:33 AM In reply to

    Re: How binding simple value to the gauge

    Steve, thank you for the feedback, I have forwarded your words to our tech writers and they will make our help more helpful.

    Regarding the resizing issue: XtraGaugeConrol has an autolayout feature that is demonstrated in our demos. When the AutoLayout is enabled, and the Gauge control has one gauge in it, it works exactly as you described.

    Feel free to ask here any questions regarding the XtraGaugeControl, I'll personally do my best to help you. I also suggest you to review our demos' source code. There are a lot of useful ideas there.

    Thanks, Roman

    R&D, .NET Team
    Developer Express Inc.

    PS. If you wish to receive direct assistance from our Support Team, use Support Center at http://www.devexpress.com/Support/Center
  • 10/24/2008 10:57 AM In reply to

    Re: How binding simple value to the gauge

    Hi I am having problems getting this code to work. It appears that after calling bind when the value changes the event is still null. Any ideas?

  • 10/24/2008 7:37 PM In reply to

    Re: How binding simple value to the gauge

    Could you be a little more specific please sam?   In the code above there is no call to a method called bind...

  • 10/27/2008 5:17 AM In reply to

    Re: How binding simple value to the gauge

    Hi Martin,

    This section of your previous post adds a databinding on the simple object. I have tried this pattern but when I change MyValue using a timer the value of
    the gauge does not change.

    // Instead of assigning a value, let's set up some data binding isntead
    scale.DataBindings.Add("Value", myObject, "MyValue", false, DataSourceUpdateMode.OnPropertyChanged);
    The reason I am not seeing the change is because there is nothing bound to the
    PropertyChanged event.

    Cheers

    Sam


  • 10/27/2008 7:02 AM In reply to

    Re: How binding simple value to the gauge

    Sam Eastburn:

    Hi Martin,

    This section of your previous post adds a databinding on the simple object. I have tried this pattern but when I change MyValue using a timer the value of
    the gauge does not change.

    // Instead of assigning a value, let's set up some data binding isntead
    scale.DataBindings.Add("Value", myObject, "MyValue", false, DataSourceUpdateMode.OnPropertyChanged);
    The reason I am not seeing the change is because there is nothing bound to the
    PropertyChanged event.

    Cheers

    Sam


    Its ok I found the problem.  On version 8.2 of the devexpress gauges the databinding on the digitalgauge does not work.  It doesn't work

    in the demo either.  I will download the latest version and see if it has been fixed.


    Sam

     

     

  • 10/28/2008 3:00 AM In reply to

    Re: How binding simple value to the gauge

    Hi

    I have registered this issue as B33551. Now it is fixed.  Thank you for the alert. Should you have any questions regarding the XtraGauges, ask them here. We'll be happy to assist you.

     

    Thanks, Roman

    R&D, .NET Team
    Developer Express Inc.

    PS. If you wish to receive direct assistance from our Support Team, use Support Center at http://www.devexpress.com/Support/Center
Page 1 of 1 (10 items)
Copyright © 1998-2008 Developer Express Inc.
ALL RIGHTS RESERVED