How do I update the current value?

Gauge for WPF Forum

Posted 9 years ago by Greg Walker - Bournemouth, England
Version: 9.2.0510
Avatar
Hi, I've just got your Gauge control & it looks great. But I can't find how to do what, to me, seems the single most important thing with it. How do I update the position of the pointer?

I have read your user guide & successfully planted one on the display with just one pointer. I can edit the load time start position, and the pointer nicely moves smoothly to the newly defined position. I tried building samples, but got lots of build errors (C# express 2008).

I'm feeling rather foolish - because this is the one key run time method that I need. Probably one line of code is all I need.

Thanks in advance,
Greg

Comments (8)

Posted 9 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Greg,

You need to update the Value property of the individual pointer elements. There are two way to gain access to that property. The first is to give the pointer element a name, so it can be accessed from code behind. So if you add x:Name="test" to the pointer, then you can access the value via code-behind like "this.test.Value = <new value>;".

The second method would be to define a dependency property (or a plain old CLR property whose object implements INotifyPropertyChanged) and bind the pointer element's Value property to that property.


Actipro Software Support

Posted 9 years ago by Greg Walker - Bournemouth, England
Avatar
Many thanks. That's all I needed.

I'm new to C#, .NET, WPF & CLR - although rather long in the tooth for C++ & OO methodology. I'm afraid your second paragraph means nothing to me, but it's not your job to educate me on that score.

I'm totally happy with assign the <Name> of the pointer (needle?) & use that to reference its <Value>. I don't need any more than that.
Posted 9 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Greg,

The following link may help: http://msdn.microsoft.com/en-us/library/ms752347.aspx

Basically, with WPF data binding the two properties bound together need to notify the WPF binding system when they change (so it knows to push the value changes back and forth). WPF adds the concept of "dependency properties", which are like "super" properties, and automatically support change notifications.

In C#/.Net you can declare simple CLR properties (like "public int MyInt { get; set; }"). The only problem with CLR properties is that they can't/don't notify anyone when they are changed. To solve this Microsoft added the INotifyPropertyChanged, which can be implemented and called from the property setters to notify when a value changed.

Hope this helps :-)


Actipro Software Support

Posted 8 years ago by Mike Marshall
Avatar
Hi

A couple of questions...

Firstly, I'm loving the look of these controls and have just purchased latest version of WPF Studio!

I am not a C# expert but understand the concept of data binding to set values of gauges.

When I add x:Name="test" to the properties of a pointer I get the following build error....

Error 1 The property 'x.Name' does not exist in XML namespace 'http://schemas.microsoft.com/winfx/2006/xaml/presentation'. Line 67 Position 62.

I have the following at top of XAML....

xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:system="clr-namespace:System;assembly=mscorlib"
xmlns:gauge="http://schemas.actiprosoftware.com/winfx/xaml/gauge"
xmlns:shared="http://schemas.actiprosoftware.com/winfx/xaml/shared"

Secondly, looking at that error it looks like it accesses this web page each time you load it. Does that mean you have to be connected to the internet to run the control. I wanted to make stand alone applications and I'm worried I won't be able to.

Sorry if above are "newbie" questions!

Any help appreciated.

Regards

Mike
Posted 8 years ago by Mike Marshall
Avatar
Sorry.. sorted thanks .. I had a typo..

Working great now!
Posted 8 years ago by Mike Marshall
Avatar
I have the guage values working but I'm struggling to get an LED state to change in the code behind?

I have

x:Name="led"

in the XAML

but there is no "led.Value" available in code behind so I can't switch LED on or OFf ?


Also, is it the same to set / read switches as I can't get these to work either.


Any help appreciated.

Thanks
Posted 8 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hello,

The LED gauge has an LedState property that can be set to On, Off, or Blinking.

The ToggleSwitch is like a checkbox; you can set the IsChecked value change the state.

Please let us know if you have further questions.


Actipro Software Support

Posted 8 years ago by Mike Marshall
Avatar
Thanks.. working now with....

led.LedState = ActiproSoftware.Windows.Controls.Gauge.LedState.On;



[Modified at 10/22/2010 02:36 AM]
The latest build of this product (v2018.1 build 0675) was released 15 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.