New to Telerik UI for WPF? Download free 30-day trial

Resolve RadGauge ArgumentException - The provided DependencyObject is not a context for this Freezable

Environment

Product Version 2017.2.614
Product RadGauge for WPF

Description

How to resolve ArgumentException with message "The provided DependencyObject is not a context for this Freezable.", when using RadGauge controls.

StackTrace:

Exception: System.ArgumentException: The provided DependencyObject is not a context for this Freezable. Parameter name: context at System.Windows.Freezable.RemoveContextInformation(DependencyObject context, DependencyProperty property) at System.Windows.Freezable.RemoveInheritanceContext(DependencyObject context, DependencyProperty property) at System.Windows.DependencyObject.RemoveSelfAsInheritanceContext(DependencyObject doValue, DependencyProperty dp) at System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType) at System.Windows.DependencyObject.SetValueCommon(DependencyProperty dp, Object value, PropertyMetadata metadata, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType, Boolean isInternal) at System.Windows.DependencyObject.SetValue(DependencyProperty dp, Object value) at Telerik.Windows.Controls.Gauge.ScaleObject.RangeChangedHandler(DependencyObject source, DependencyPropertyChangedEventArgs eventArgs) .......

Solution

This can happen in a scenario with multiple gauge controls with animated indicators (like the Needle element) that are updated very fast at runtime (on a small time interval). To resolve this, disable the animation of the indicators. To do this set their IsAnimated property to False.

<telerik:Needle IsAnimated="False" />  
In this article