Is GaugeColorValueRange min/maxvalues bindable?

4 posts, 0 answers
  1. Magnus
    Magnus avatar
    5 posts
    Member since:
    Mar 2009

    Posted 09 Aug 2011 Link to this post

    I am trying to data bind my GaugeColorValueRange to my MVVM view model, but it fails.
    In the designer, I get this exception:
    System.Reflection.TargetInvocationException
    Exception has been thrown by the target of an invocation.
       at System.RuntimeMethodHandle._InvokeMethodFast(IRuntimeMethodInfo method, Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeType typeOwner)
       at System.RuntimeMethodHandle.InvokeMethodFast(IRuntimeMethodInfo method, Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeType typeOwner)
       at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
       at System.Delegate.DynamicInvokeImpl(Object[] args)
       at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
       at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
     
      
    System.InvalidOperationException
    Layout measurement override of element 'Microsoft.Windows.Design.Platform.SilverlightViewProducer+SilverlightContentHost' should not return PositiveInfinity as its DesiredSize, even if Infinity is passed in as available size.
       at System.Windows.UIElement.Measure(Size availableSize)
       at MS.Internal.Designer.DeviceSkinViewPresenter.DeviceDesignerBackground.MeasureOverride(Size constraint)
       at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
       at System.Windows.UIElement.Measure(Size availableSize)
       at System.Windows.Controls.Decorator.MeasureOverride(Size constraint)
       at Microsoft.Windows.Design.Interaction.DesignerView.MeasureOverride(Size constraint)
       at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
       at System.Windows.UIElement.Measure(Size availableSize)
       at MS.Internal.Designer.Viewport.MeasureOverride(Size availableSize)
       at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
       at System.Windows.UIElement.Measure(Size availableSize)
       at MS.Internal.Helper.MeasureElementWithSingleChild(UIElement element, Size constraint)
       at System.Windows.Controls.ScrollContentPresenter.MeasureOverride(Size constraint)
       at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
       at System.Windows.UIElement.Measure(Size availableSize)
       at System.Windows.Controls.Grid.MeasureCell(Int32 cell, Boolean forceInfinityV)
       at System.Windows.Controls.Grid.MeasureCellsGroup(Int32 cellsHead, Size referenceSize, Boolean ignoreDesiredSizeU, Boolean forceInfinityV)
       at System.Windows.Controls.Grid.MeasureOverride(Size constraint)
       at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
       at System.Windows.UIElement.Measure(Size availableSize)
       at System.Windows.Controls.ScrollViewer.MeasureOverride(Size constraint)
       at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
       at System.Windows.UIElement.Measure(Size availableSize)
       at System.Windows.Controls.Grid.MeasureOverride(Size constraint)
       at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
       at System.Windows.UIElement.Measure(Size availableSize)
       at MS.Internal.Helper.MeasureElementWithSingleChild(UIElement element, Size constraint)
       at System.Windows.Controls.ContentPresenter.MeasureOverride(Size constraint)
       at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
       at System.Windows.UIElement.Measure(Size availableSize)
       at System.Windows.Controls.Control.MeasureOverride(Size constraint)
       at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
       at System.Windows.UIElement.Measure(Size availableSize)
       at System.Windows.Interop.HwndSource.SetLayoutSize()
       at System.Windows.Interop.HwndSource.set_RootVisualInternal(Visual value)
       at System.Windows.Interop.HwndSource.set_RootVisual(Visual value)
       at MS.Internal.DeferredHwndSource.ProcessQueue(Object sender, EventArgs e)

    And at runtime, I get this error:
    System.Windows.Markup.XamlParseException occurred
      Message=AG_E_PARSER_BAD_PROPERTY_VALUE [Line: 38 Position: 50]
      LineNumber=38
      LinePosition=50
      StackTrace:
           at System.Windows.Application.LoadComponent(Object component, Uri resourceLocator)
           at xxxxxxxxxx.MainPage.InitializeComponent()
           at xxxxxxxxxx.MainPage..ctor()
           at System.Reflection.RuntimeConstructorInfo.InternalInvoke(RuntimeConstructorInfo rtci, BindingFlags invokeAttr, Binder binder, Object parameters, CultureInfo culture, Boolean isBinderDefault, Assembly caller, Boolean verifyAccess, StackCrawlMark& stackMark)
           at System.Reflection.RuntimeConstructorInfo.InternalInvoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, StackCrawlMark& stackMark)
           at System.Activator.InternalCreateInstance(Type type, Boolean nonPublic, StackCrawlMark& stackMark)
           at System.Activator.CreateInstance(Type type)
           at System.Windows.Navigation.PageResourceContentLoader.BeginLoad_OnUIThread(AsyncCallback userCallback, PageResourceContentLoaderAsyncResult result)
           at System.Windows.Navigation.PageResourceContentLoader.<>c__DisplayClass4.<BeginLoad>b__0(Object args)
           at System.Reflection.RuntimeMethodInfo.InternalInvoke(RuntimeMethodInfo rtmi, Object obj, BindingFlags invokeAttr, Binder binder, Object parameters, CultureInfo culture, Boolean isBinderDefault, Assembly caller, Boolean verifyAccess, StackCrawlMark& stackMark)
           at System.Reflection.RuntimeMethodInfo.InternalInvoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, StackCrawlMark& stackMark)
           at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)
           at System.Delegate.DynamicInvokeOne(Object[] args)
           at System.MulticastDelegate.DynamicInvokeImpl(Object[] args)
           at System.Delegate.DynamicInvoke(Object[] args)
           at System.Windows.Threading.DispatcherOperation.Invoke()
           at System.Windows.Threading.Dispatcher.Dispatch(DispatcherPriority priority)
           at System.Windows.Threading.Dispatcher.OnInvoke(Object context)
           at System.Windows.Hosting.CallbackCookie.Invoke(Object[] args)
           at System.Windows.Hosting.DelegateWrapper.InternalInvoke(Object[] args)
           at System.Windows.RuntimeHost.ManagedHost.InvokeDelegate(IntPtr pHandle, Int32 nParamCount, ScriptParam[] pParams, ScriptParam& pResult)

    Line 38 in my Xaml is of course where I have define the GaugeColorValueRange object:
         <Grid.Resources>
             <local:GaugeExampleDoubleToStringConverter x:Key="valueToStringConverter"/>
             <gauges:GaugeValueToBrushConverter x:Key="converter1"
                                            DefaultColor="SlateGray">
             </gauges:GaugeValueToBrushConverter>
             <gauges:GaugeValueToBrushConverter x:Key="converter2"
                                            DefaultColor="SlateGray">
    <!-- This would be line 38 -->             <gauges:GaugeColorValueRange MinValue="{Binding SpeedMarker}"
                                     MaxValue="50"
                                     Color="Red"/>
             </gauges:GaugeValueToBrushConverter>
         </Grid.Resources>

    My View Model property (using MVVM Light):
    private double _speedMarker;
    public double SpeedMarker
    {
      get { return _speedMarker; }
      set
      {
        if (value != _speedMarker)
        {
          _speedMarker = value;
          RaisePropertyChanged("SpeedMarker");
        }
      }
    }

    I have data bound several other Gauge property values, but this one fails.
    Am I doing something wrong?

    Regards,
    Magnus

  2. Victor
    Admin
    Victor avatar
    1351 posts

    Posted 11 Aug 2011 Link to this post

    Hi Magnus,

     Thank you for the question. Currently the GaugeValueToBrushConverter is a plain CLR object, not a DependencyObject and therefore its properties and ranges are not dependency objects. The destination of a Silverlight binding has to be a DependencyProperty. Since the MinValue of ColorValueRange is not a DependencyProperty, it can not be bound.

    We did not create the converter as a DependencyObject because we assumed that these color ranges will be static, that is, will not have to update dynamically. Since you are requesting such functionality we will update the gauge converters to be bindable for one of the future releases.

    Please write again if you have other questions.

    Best wishes,
    Victor
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

  3. DevCraft banner
  4. Amit
    Amit avatar
    1 posts
    Member since:
    Oct 2012

    Posted 08 Nov 2012 Link to this post

    Now GaugeColorValueRange Min/MaxValue are bindable?
  5. Victor
    Admin
    Victor avatar
    1351 posts

    Posted 08 Nov 2012 Link to this post

    Hello Amit,

    Thanks for writing.
    The ranges are not yet updated to be dependency objects since no one else has asked for this change. We will update them for the upcoming service pack which will be released in early December.
    Thanks for understanding.

    All the best,
    Victor
    the Telerik team
    Have a suggestion or face a problem - you can use the Ideas & Feedback portal to submit ideas, feedback and vote for them.
Back to Top