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
close icon

WinRT SfCircularGauge does nothing ...


... even though the value i am binding to changes. What am i missing here?

this is the xaml of the needlepointer that i want to see moving. Is there a problem with the binding here? The value i am binding to is a double.

<syncfusion:CircularPointer PointerType="RangePointer" Value="{Binding MyViewModel.GaugeValue, Mode=TwoWay}" NeedlePointerStroke="{StaticResource MyBrushes_Foreground}" />

greetings


14 Replies

JO Joy Oyiess Rex  K Syncfusion Team March 7, 2013 05:07 AM UTC

Hi Martin,

Thanks for using Syncfusion Products.

As per the implementation, the CircularPointer in the CircularScale is of type DependencyObject. So it does not have any DataContext from its parent. Therefore while bind the value for the CircularPointer it does not have any DataContext as its Source.

Therefore we can achieve this scenario through the following Code Snippet:

·         Set the Resource

<Page.Resources>

    <local1:MyViewModel x:Key="dataSource" />

</Page.Resources>

 

·         Bind the Value Property by set the Resource key as a Source

 

<syncfusion:CircularScale.Pointers>

   <syncfusion:CircularPointer  PointerType="NeedlePointer" Value="{Binding Source={StaticResource dataSource}, Path=Value}"  />

</syncfusion:CircularScale.Pointers>

 

 

·         Inorder to Move the NeedlePointer we can bind it with a slider with the same object as a source to move the pointer dynamically.

·         Set the DataContext for the parent grid of the Slider.

      <Grid DataContext="{Binding Source={StaticResource dataSource}}"  >

 

     <Slider Value="{Binding Value,Mode=TwoWay}" Minimum="0" Maximum="100" />

 

Note : In your Code Snippet you have mentioned that the PointerType property is Set as RangePointer and you have used used NeedlePointerStroke Property in it. Instead of that you can use RangePointerStroke property to apply stroke for the pointer.

We have also attached a sample for the same.

 

Regards,

Joy Oyiess Rex.K



CircularGaugeNeedleBindSample_dc492c70.zip


MA Martin March 8, 2013 12:06 PM UTC

Thanks for your reply!

Unfortunately MyViewModel is Singleton-class with only one instance in my case.

So i cant't use the code:
<Page.Resources>
    <local1:MyViewModel x:Key="dataSource" />
</
Page.Resources>

.. because that would be the same is MyViewModel test1 = new MyViewModel (), which is not possible due to the inaccessible constructor of my singleton class.

So basically i would like to bind the needle-value to a property of a singleton-class. Is this possible?



Note: When i want to bind to another element (e.g. a textblock) i do it like this:

Code behind:
this.DefaultViewModel["Blabla"] = MyViewModel.Instance;

Xaml:
<TextBlock Text="{Binding Blabla.GaugeValue}" />


Greetings from austria! :)




BS Baskaran S Syncfusion Team March 11, 2013 01:30 PM UTC

Hi Martin,

Thanks for your update.

As you have mentioned we have created a Singleton class for changing the value of the CircularGauge pointer. For your reference we have attached the sample below.

Please try the sample and let us know if this helps you. Please let us know if you require further clarifications.

Regards,

Baskaran S

 



CircularGaugeNeedleBindSample_3aa6a916.zip


MA Martin March 12, 2013 12:06 PM UTC


Works like a charm! Thanks a lot for your help!


JO Joy Oyiess Rex  K Syncfusion Team March 13, 2013 05:59 AM UTC

Hi Martin,

Thanks for your feedback.

Please let us know, if you have any further assistance.

Regards,

Joy Oyiess Rex.K



CC Cesar Calvo Cobo July 30, 2013 10:56 AM UTC

Hi, I have got the same problem . 
Trying to set dynamically the value of the circular pointer binding with local resources  , with no luck. 
I can not access the element name in code behind because is inside a tabcontrol 

Any workaround? 

I am using last version of winrt controls: 11.2.0.29

Thanks in advance 




Resources   
 <local:DataSourceCompetencias x:Key="DatosCompetencias"/>

Binding

                                                    <Gauges:CircularPointer x:Name="valorcompetencia" EnableAnimation="False" PointerCapDiameter="20" PointerType="NeedlePointer" NeedlePointerStroke="#39b2c6" NeedlePointerStrokeThickness="3" NeedleLengthFactor="0.6" PointerCapStroke="#414d4f"   Value="{Binding Source={StaticResource DatosCompetencias}, Path=Media}"  />


Model: 
public class DataSourceCompetencias
    {
        public ObservableCollection<Competencia> ListaCompetencias { get; set; }

        public DataSourceCompetencias()
        {
            Initialize();
        }

        public void Initialize()
        {
            ListaCompetencias = new ObservableCollection<Competencia>();
            ListaCompetencias.Add(new Competencia("Nombre1", 3));
            ListaCompetencias.Add(new Competencia("Nombre2", 4));
            ListaCompetencias.Add(new Competencia("Nombre3", 2));
        }

public class Competencia
    {
         public Competencia(string nombre, int media)
        {
            Media = media;
            Nombre = nombre;
        }
        public int UserID { get; set; }

        [Key]
        [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
        public int CompetenciaID { get; set; }

        public string Nombre { get; set; }
        public string F1 { get; set; }
        public int PUNTF1 { get; set; }
        public string F2 { get; set; }
        public int PUNTF2 { get; set; }
        public string F3 { get; set; }
        public int PUNTF3 { get; set; }
        public int Media { get; set; }
         


    }
    
       





CC Cesar Calvo Cobo July 30, 2013 11:16 AM UTC

Update : I am solving it temporarily creating collapsed control out of circularpointer , binding the datasource to this control and binding the circular pointer to this element .
Not the best solution, of course .




JO Joy Oyiess Rex  K Syncfusion Team July 31, 2013 07:22 AM UTC

Hi Cesar,

 

Thank you for using Syncfusion Products.

 

Based on your requirement we have created a simple sample to dynamically update the Value of the CircularPointer (in the tab control). Please find the sample in the attachment.

If the provided solution doesn't meet your requirement, Please revert us back with more information by thus we could assist you better.

 

Please  let us know, if you need any further assistance.

 

Best Regards,

Joy Oyiess Rex K



CircularGaugeNeedleBindSample_378f557a.zip


CC Cesar Calvo Cobo July 31, 2013 09:51 AM UTC

Great sample and support! Thank you . 


JO Joy Oyiess Rex  K Syncfusion Team August 1, 2013 04:37 AM UTC

Hi Cesar,

Thanks for your feedback.

Please let us know, if you need any further assistance.

Beat Regards,
Joy Oyiess Rex.K


NW Nick Woessner October 2, 2013 05:27 PM UTC

I am having the same issue as Martin was, except in WPF. Can I get a copy of the sample you provided him.

 

Thanks



JO Joy Oyiess Rex  K Syncfusion Team October 4, 2013 04:38 AM UTC

Hi Nick,

 

Thanks for your interest in Syncfusion Products.

 

We have attached the samples in the attachment below,

 

Please let us know, if you need any further assistance.

 

Regards,

Joy Oyiess Rex K



CircularGaugeNeedleBindSample_2eebd2d1.zip


DT Daniel Thompson June 16, 2014 08:17 PM UTC

Hi,

Whenever I try to download these samples, I get a blob of xml that says "not authorized". Can you enable them for download please?


NM Nijamudeen Mohamed Sulaiman Syncfusion Team June 17, 2014 12:45 PM UTC

Hi Daniel,

 

Thanks for your interest in Syncfusion Products.

 

Due to some server issue we are unable to retrieve these samples. As of now we have prepared a sample related to this query. Please find the sample in the attachment.

 

Please let us know, if you need any further assistance.

 

Regards,

Nijamudeen M.


Attachment: CircularGaugeNeedleBindSample_a463df83.zip

Loader.
Live Chat Icon For mobile
Up arrow icon