Hi,
I need to create gauges dynamically and put them in a WrapPanel. So I created a user control as follows:
The code behind looks like:
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:
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
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> |
| namespace WMITest |
| { |
| /// <summary> |
| /// Interaction logic for PercentUtilizationGauge.xaml |
| /// </summary> |
| public partial class PercentUtilizationGauge : UserControl |
| { |
| public uint Value { get; set; } |
| 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(this, new PropertyChangedEventArgs(name)); |
| } |
| } |
| #endregion |
| } |
| } |
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