Problem adding more than one gauge

7 posts, 0 answers
  1. Ambar Kulkarni
    Ambar Kulkarni avatar
    12 posts
    Member since:
    Mar 2010

    Posted 28 Apr 2010 Link to this post

    Hi,

    I need to create gauges dynamically and put them in a WrapPanel. So I created a user control as follows:

    <UserControl x:Class="WMITest.PercentUtilizationGauge" 
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
        xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation" 
        xmlns:local="clr-namespace:WMITest" 
        Height="300" Width="300">  
        <UserControl.Resources> 
            <local:GaugeSettings x:Key="DataSource"/>  
        </UserControl.Resources> 
        <telerik:RadGauge DataContext="{Binding Source={StaticResource DataSource}}">  
            <Grid> 
                <telerik:RadialGauge HorizontalAlignment="Stretch" VerticalAlignment="Stretch">  
                    <telerik:RadialScale LabelRotationMode="None" Name="radialScale" Min="0" Max="100">  
                        <telerik:RangeList> 
                            <telerik:RadialRange Name="Green" Min="0" Max="{Binding GreenZoneEnd}" StartWidth="0.1" EndWidth="0.1" 
                                        Location="OverCenter" Background="Green" BorderBrush="Green" Opacity="0.8"/>  
                            <telerik:RadialRange Name="Yellow" Min="{Binding GreenZoneEnd}" Max="{Binding YellowZoneEnd}" StartWidth="0.1" EndWidth="0.1" 
                                        Location="OverCenter" Background="Yellow" BorderBrush="Yellow" Opacity="0.8"/>  
                            <telerik:RadialRange Name="Red" Min="{Binding YellowZoneEnd}" Max="100" StartWidth="0.1" EndWidth="0.1" 
                                        Location="OverCenter" Background="Red" BorderBrush="Red" Opacity="0.8"/>  
                        </telerik:RangeList> 
                        <telerik:IndicatorList> 
                            <telerik:Needle Opacity="0.8" Name="needle"/>  
                        </telerik:IndicatorList>                      
                    </telerik:RadialScale> 
                </telerik:RadialGauge> 
            </Grid> 
        </telerik:RadGauge> 
    </UserControl> 
    The code behind looks like:
    namespace WMITest  
    {  
        /// <summary>  
        /// Interaction logic for PercentUtilizationGauge.xaml  
        /// </summary>  
        public partial class PercentUtilizationGauge : UserControl  
        {  
            public uint Value { getset; }  
            public GaugeSettings Settings;  
     
            public PercentUtilizationGauge()  
            {  
                if (Settings == null)  
                {  
                    Settings = new GaugeSettings();  
                }  
     
                InitializeComponent();  
     
                Settings.GreenZoneEnd = 60;  
            }  
        }  
     
        public class GaugeSettings : INotifyPropertyChanged  
        {  
            private uint greenZoneEnd = 40;  
            public uint GreenZoneEnd  
            {  
                get 
                {  
                    return greenZoneEnd;  
                }  
     
                set 
                {  
                    greenZoneEnd = value;  
                    OnPropertyChanged("GreenZoneEnd");  
                }  
            }  
     
            private uint yellowZoneEnd = 80;  
            public uint YellowZoneEnd  
            {  
                get 
                {  
                    return yellowZoneEnd;  
                }  
     
                set 
                {  
                    yellowZoneEnd = value;  
                    OnPropertyChanged("YellowZoneEnd");  
                }  
            }
            #region INotifyCollectionChanged Members  
            public event PropertyChangedEventHandler PropertyChanged;  
            protected void OnPropertyChanged(string name)  
            {  
                PropertyChangedEventHandler handler = PropertyChanged;  
                if (handler != null)  
                {  
                    handler(thisnew PropertyChangedEventArgs(name));  
                }  
            }
            #endregion  
        }  
    It all works fine if I add just one PercentUtilizationGauge to the WrapPanel. However as soon as I add second PercentUtilizationGauge several excaptions of type System.InvalidOperationException are thrown:

    A first chance exception of type 'System.InvalidOperationException' occurred in System.Core.dll

    Additional information: Sequence contains no matching element


    They all seem to occur in Telerik code - the call stack looks like:

    > System.Core.dll!System.Linq.Enumerable.First<object>(System.Collections.Generic.IEnumerable<object> source, System.Func<object,bool> predicate) + 0x150 bytes 
      Telerik.Windows.Controls.Gauge.dll!Telerik.Windows.Controls.Gauges.ScaleBase.FindOffPosition(Telerik.Windows.Controls.Gauges.IGaugeIndicator indicator = {Telerik.Windows.Controls.Gauges.Needle}) Line 1930 + 0x7b bytes C#
      Telerik.Windows.Controls.Gauge.dll!Telerik.Windows.Controls.Gauges.RadialScale.ArrangeIndicator(Telerik.Windows.Controls.Gauges.IGaugeIndicator indicator = {Telerik.Windows.Controls.Gauges.Needle}) Line 314 + 0xc bytes C#
      Telerik.Windows.Controls.Gauge.dll!Telerik.Windows.Controls.Gauges.IndicatorBase.ArrangeOverride(System.Windows.Size finalSize = {162,30}) Line 1121 C#
      Telerik.Windows.Controls.Gauge.dll!Telerik.Windows.Controls.Gauges.Needle.ArrangeOverride(System.Windows.Size finalSize = {162,30}) Line 94 + 0x26 bytes C#

    So how do I find out what is going wrong here? Any help would be greatly appreciated.
    Thanks

    -Ambar
  2. Miha Markic
    Miha Markic avatar
    48 posts
    Member since:
    Jan 2006

    Posted 29 Apr 2010 Link to this post

    Perhaps those exceptions are internally handled, are they? In that case I think you've hit the same problem I did. telerik says it will be corrected in next version.
  3. UI for WPF is Visual Studio 2017 Ready
  4. Andrey
    Admin
    Andrey avatar
    1681 posts

    Posted 29 Apr 2010 Link to this post

    Hello Ambar,

    Thanks, Miha. That's correct. These are handled internally. We will change this behavior in the next version.

    Kind regards,
    Andrey Murzov
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  5. Ambar Kulkarni
    Ambar Kulkarni avatar
    12 posts
    Member since:
    Mar 2010

    Posted 29 Apr 2010 Link to this post

    Miha & Andrey

    Thanks for your replies. I am worried about a flood of these exceptions since I will be adding many more gauges dynamically. But I guess as long as they are caught and handled internally, it should be fine. However, I am still curious about what is causing these exceptions - is it someting in my code or something in the gauge code iteself?

    -Ambar
  6. Andrey
    Admin
    Andrey avatar
    1681 posts

    Posted 29 Apr 2010 Link to this post

    Hi Ambar Kulkarni,

    These exceptions are not triggered by your code. There is a code inside  gauge implementation which could throw an exception. It will be changed in the future release.

    Best wishes,
    Andrey Murzov
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  7. Andulvar
    Andulvar avatar
    3 posts
    Member since:
    Feb 2011

    Posted 01 Apr 2011 Link to this post

    This problem still exists.  Create a page with some circular gauges on it and then change the needle position based on a timer.  For us, using Silverlight 4 and the latest gauge download (as of Apr 1,2011), we get a first-chance exception every time the needle changes position.

    That might not be a problem for the occasional change, but we are trying to use the gauge to show smooth motion with a fairly quick input.  If we put six gauges on the screen and move all of their needles, that's pretty much the end of the CPU on a moderate machine.  We believe that is due to exceptions firing continuously deep inside the gauge.  The VS debugger supports this theory.

    If you believe that this was fixed at some point then perhaps this is a new case.  If not, do you have a timetable for when it might be?  For us it's a fatal error.  We cannot use or recommend this gauge while the bug persists.
  8. Andrey
    Admin
    Andrey avatar
    1681 posts

    Posted 06 Apr 2011 Link to this post

    Hi Ambar Kulkarni,

    Thank you for the feedback. We will fix the problem. The fix will be available in the nearest internal build.

    Regards,
    Andrey Murzov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Back to Top
UI for WPF is Visual Studio 2017 Ready