We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

How can you use data binding in Gauge with the MVVM pattern?

In order to achieve data binding in Gauge with MVVM pattern, you can refer the following procedure.

Create a new Forms Xaml Page in the PCL project and include the SfCircularGauge Xaml code in it.

Set the created Forms Xaml page as a MainPage in the constructor of the App class.

C#

Include the required code example for Circular Gauge in the Forms Xaml Page. Here it is named as the HomePage.

Once you have included the Circular Gauge related code examples, set the ViewModel as a BindingContext for the SfCircularGauge.

XAML

The ViewModel implements INotifyPropertyChanged, so that the view is notified once the Value property gets changed.

C#

So that Value property in the CircularPointer in the CircularGauge control can be dynamically updated by updating the Value property in the ViewModel.

Article ID: Published Date: Last Revised Date: Platform: Control: Product Version:
4138 02/23/2015 02/23/2015 Xamarin.Forms SfCircularGauge 12.4.0.24
Tags:
Did you find this information helpful?
Comments
Renault Hess Apr 24, 2018

Hi, If I set Needle value to an explicit value, it displays on the app when I run it, however, If I use the binding as above, I get a null reference pointer when the app starts (in debug mode). Any ideas?

Reply
Renault Hess Apr 24, 2018

PS I also have a label independent of the gauge, with the same binding, and when I comment out the Gauge xaml, tie label updates properly

Sri Gayathri Gopalakrishnan [Syncfusion] Apr 25, 2018

Hi Renault,

We have validated your query and the above code working fine for dynamic binding. Please find the complete sample for the above code,

http://www.syncfusion.com/downloads/support/directtrac/general/ze/Duration2120625359

Regards,
Sri Gayathri. G

Reply
Add Comment
You must log in to leave a comment

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.