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. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

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

Platform: Xamarin.Forms |
Control: SfCircularGauge |
Product Version: 12.4.0.24

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.

2X faster development

The ultimate Xamarin UI toolkit to boost your development speed.
ADD COMMENT
You must log in to leave a comment
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
Feles Mala
Aug 18, 2022

Hi there,

I'm really enjoying the controls library, and I have a perfect use for a radial gauge, however there's no way to customise the label text on the gauge in an mvvm manner!

The LabelCreated event needs to be a binding,

Please advise!

Thanks,Greg

Reply

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon 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.Close Icon

Live Chat Icon For mobile