Needle Value Property Binding Not Working

7 posts, 0 answers
  1. Todor
    Todor avatar
    10 posts
    Member since:
    Aug 2008

    Posted 11 Mar 2009 Link to this post

    Hi,

    Yesterdaty I was at a lecture on Architecture Patterns for Silverlight held by Deyan Varchev from Telerik. There I asked a question of a problem I have with a Needle control inside a Gauge and I was asked to supply the example solution, so here it is.

    Page.xaml:
    <UserControl x:Class="GaugeTest.Page" 
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"  
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"  
        Width="400" Height="336" xmlns:Telerik_Windows_Controls_Gauges="clr-namespace:Telerik.Windows.Controls.Gauges;assembly=Telerik.Windows.Controls.Charting"
        <Grid x:Name="LayoutRoot" Background="White"
     
            <Telerik_Windows_Controls_Gauges:RadialGauge Height="250" Margin="75,8,75,78" Width="250"
                <Telerik_Windows_Controls_Gauges:RadialScale Height="Auto" Width="Auto" Min="0" Max="400"
                    <Telerik_Windows_Controls_Gauges:RadialScale.Indicators> 
                        <Telerik_Windows_Controls_Gauges:Needle Value="{Binding Path=DoubleValue, Mode=OneWay}"/> 
                    </Telerik_Windows_Controls_Gauges:RadialScale.Indicators> 
                </Telerik_Windows_Controls_Gauges:RadialScale> 
            </Telerik_Windows_Controls_Gauges:RadialGauge> 
             
            <StackPanel Height="Auto" Margin="8,0,8,8" VerticalAlignment="Bottom" Orientation="Horizontal" HorizontalAlignment="Center"
                <Button Height="27" Content="Set new random value" Click="Button_Click" Margin="0,0,10,0"/> 
                <TextBlock Height="Auto" Width="Auto" Text="New Value:" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="0,0,10,0"/> 
                <TextBox Height="Auto" Width="150" Text="{Binding Path=DoubleValue, Mode=TwoWay}" TextWrapping="Wrap" VerticalAlignment="Center" Margin="0,2,0,2"/> 
            </StackPanel> 
     
        </Grid> 
    </UserControl> 
     

    Page.xaml.cs:
    using System; 
    using System.Collections.Generic; 
    using System.Linq; 
    using System.Net; 
    using System.Windows; 
    using System.Windows.Controls; 
    using System.Windows.Documents; 
    using System.Windows.Input; 
    using System.Windows.Media; 
    using System.Windows.Media.Animation; 
    using System.Windows.Shapes; 
     
    namespace GaugeTest 
        public partial class Page : UserControl 
        { 
            private DummyClass dc; 
            private Random rnd; 
     
            public Page() 
            { 
                InitializeComponent(); 
     
                dc = new DummyClass(); 
                LayoutRoot.DataContext = dc; 
     
                rnd = new Random(); 
                dc.GenerateNewNumber(rnd); 
            } 
     
            private void Button_Click(object sender, RoutedEventArgs e) 
            { 
                dc.GenerateNewNumber(rnd); 
            } 
        } 
     

    And here is the DummyClass definition:
    using System; 
    using System.Net; 
    using System.Windows; 
    using System.Windows.Controls; 
    using System.Windows.Documents; 
    using System.Windows.Ink; 
    using System.Windows.Input; 
    using System.Windows.Media; 
    using System.Windows.Media.Animation; 
    using System.Windows.Shapes; 
    using System.ComponentModel; 
     
    namespace GaugeTest 
        public class DummyClass : INotifyPropertyChanged 
        { 
            #region INotifyPropertyChanged Members 
     
            public event PropertyChangedEventHandler PropertyChanged; 
            #endregion 
     
            private double m_DoubleValue; 
     
            public DummyClass() 
            { 
                DoubleValue = 0; 
            } 
     
            public double DoubleValue 
            { 
                get 
                { 
                    return m_DoubleValue; 
                } 
                set 
                { 
                    m_DoubleValue = value; 
                    NotifyPropertyChanged("DoubleValue"); 
                } 
            } 
     
            public void GenerateNewNumber(Random rnd) 
            { 
                int newValue = rnd.Next(0, 400); 
     
                DoubleValue = (double)newValue; 
            } 
     
            private void NotifyPropertyChanged(string propertyName) 
            { 
                if (PropertyChanged != null
                { 
                    PropertyChanged(this
                        new PropertyChangedEventArgs(propertyName)); 
                } 
            } 
        } 
     

    When you start the application and start pressing the Button to generate different random values for the DoubleValue Property of the DummyClass, the Text Property of the TextBox is changed as expected, but the Needle of the Gauge stays on "0" at all times. Am I doing something wrong ?
  2. Andrey
    Admin
    Andrey avatar
    1681 posts

    Posted 12 Mar 2009 Link to this post

    Hello Todor,

    Indeed we must admit we are aware of this problem and our developers were already able to address it accordingly. The fix will be included in the Q1 2009 release that is due today.

    Hope this helps.

    Greetings,
    Andrey Murzov
    the Telerik team


    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  3. DevCraft banner
  4. ManniAT
    ManniAT avatar
    877 posts
    Member since:
    Nov 2003

    Posted 16 Apr 2009 Link to this post

    Hi,

    I guess I have almost the same problem.
    I bind my data to a marker like this:
    <gauge:Marker x:Name="gauge_markerCPU" Value="{Binding Path=CPUPercent, Mode=OneWay}"  
    And I also bind the same to a textblock.
    Than I call a webservice which retrives the value - bind it - and it does what it should.
    BUT - on further calls the marker stays on it's initial position (the one from the first call) and does not move.
    Data is OK - as the texbox shows.

    AND - I use the latest version 2009.1.413.1020.

    Regards

    Manfred
  5. Andrey
    Admin
    Andrey avatar
    1681 posts

    Posted 17 Apr 2009 Link to this post

    Hello Manfred,

    We’ve fixed the problem described by Todor in Q1 release. Binding now works for indicators in Silverlight. Your problem is a bit different. Using of the animation on the property which is bound to some data provider brakes binding. It doesn’t matter is it our internal animation object, or you will create own one in application. Binding will be destroyed. It is not a problem with our control, but how things work in Silverlight. This is a real problem. We currently are working on it and looking for the solution. As a workaround I could recommend to not animate indicators which are bound to the data. Or create your own external animation.

    Sincerely yours,
    Andrey Murzov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  6. ManniAT
    ManniAT avatar
    877 posts
    Member since:
    Nov 2003

    Posted 17 Apr 2009 Link to this post

    Thank you for this information.

    The workaround (in my case) is not a problem.
    Instead of binding the data - I set marker.Value in code which works.
    Since I get the data from a webservice this is very easy in this case.

    Regards

    Manfred
  7. Darek
    Darek avatar
    16 posts
    Member since:
    Mar 2009

    Posted 03 Jun 2009 Link to this post

    Quick update: this problem still exists in version 2009.1.526.1020. It responds initially, than stops updates. And I'd rather not do direct Value updates, since the entire project relies on MVVM.
  8. Andrey
    Admin
    Andrey avatar
    1681 posts

    Posted 08 Jun 2009 Link to this post

    Hello Darek,

    Here is my answer to this question in the other thread you have started:

    It is the animation that breaks binding on the Silverlight controls. Unfortunately, the same problem exists for animated indicators in RadGauge (turning on the animation by setting IsAnimated property to "True" value brakes binding). We aware of this problem and we are working on the fix for it. We plan to have it fixed for the Q2 release.


    Sincerely,
    Andrey Murzov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
Back to Top
DevCraft banner