Hi,
Im using the RadSemicircleNorthGauge in a MVVM Silvelright 4 application and need to define some ranges for the control. I added some GaugeRanges in Blend and the designer showed them as I added them without any problems. But when i began to run the application i started getting some weird errors. So i began commenting our some code and finally found out that it was the GaugeRanges defined in xaml that where acting up with Caliburn.Micro.
The error:
Reference is not a valid visual DependencyObject.
{System.InvalidOperationException: Reference is not a valid visual DependencyObject.
at System.Windows.Media.VisualTreeHelper.GetRelative(DependencyObject reference, RelativeKind relativeKind)
at System.Windows.Media.VisualTreeHelper.GetChildrenCount(DependencyObject reference)
at Caliburn.Micro.BindingScope.<.cctor>b__3(DependencyObject elementInScope)
at Caliburn.Micro.ViewModelBinder.<.cctor>b__3(Object viewModel, DependencyObject view, Object context)
at Caliburn.Micro.Bootstrapper.DisplayRootViewFor(Application application, Type viewModelType)
at Caliburn.Micro.Bootstrapper`1.OnStartup(Object sender, StartupEventArgs e)
at MS.Internal.CoreInvokeHandler.InvokeEventHandler(UInt32 typeIndex, Delegate handlerDelegate, Object sender, Object args)
at MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, Int32 actualArgsTypeIndex, String eventName, UInt32 flags)}
Code that gives the error in Caliburn.Micro:
current in this case is {Telerik.Windows.Controls.Gauge.GaugeRange}
BindingScope.cs
var childCount = VisualTreeHelper.GetChildrenCount(current);
This is the code that gave me the error:
My workaround:
I added the ranges to the Gauge in code behind.
Below is a link to a sample project that will give the error.
http://www.burgundi.com/wp-content/uploads/2012/03/CaliburnGaugeTest.zip
Is this something that can be resolved since i don´t want any code in my code behind?
Regards,
Sebastian
Im using the RadSemicircleNorthGauge in a MVVM Silvelright 4 application and need to define some ranges for the control. I added some GaugeRanges in Blend and the designer showed them as I added them without any problems. But when i began to run the application i started getting some weird errors. So i began commenting our some code and finally found out that it was the GaugeRanges defined in xaml that where acting up with Caliburn.Micro.
The error:
Reference is not a valid visual DependencyObject.
{System.InvalidOperationException: Reference is not a valid visual DependencyObject.
at System.Windows.Media.VisualTreeHelper.GetRelative(DependencyObject reference, RelativeKind relativeKind)
at System.Windows.Media.VisualTreeHelper.GetChildrenCount(DependencyObject reference)
at Caliburn.Micro.BindingScope.<.cctor>b__3(DependencyObject elementInScope)
at Caliburn.Micro.ViewModelBinder.<.cctor>b__3(Object viewModel, DependencyObject view, Object context)
at Caliburn.Micro.Bootstrapper.DisplayRootViewFor(Application application, Type viewModelType)
at Caliburn.Micro.Bootstrapper`1.OnStartup(Object sender, StartupEventArgs e)
at MS.Internal.CoreInvokeHandler.InvokeEventHandler(UInt32 typeIndex, Delegate handlerDelegate, Object sender, Object args)
at MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, Int32 actualArgsTypeIndex, String eventName, UInt32 flags)}
Code that gives the error in Caliburn.Micro:
current in this case is {Telerik.Windows.Controls.Gauge.GaugeRange}
BindingScope.cs
var childCount = VisualTreeHelper.GetChildrenCount(current);
This is the code that gave me the error:
<
telerik:RadSemicircleNorthGauge
Grid.Row
=
"1"
Style
=
"{StaticResource RadSemiCircleNorthGaugeStyle}"
>
<
telerik:RadialScale
x:Name
=
"radialScale"
MajorTickStroke
=
"{StaticResource BackgroundBlack}"
Foreground
=
"{x:Null}"
MiddleTickStroke
=
"{x:Null}"
MiddleTickBackground
=
"{x:Null}"
MajorTickBackground
=
"{x:Null}"
MinorTickBackground
=
"{x:Null}"
MinorTickStroke
=
"{x:Null}"
>
<
telerik:RadialScale.Ranges
>
<
telerik:GaugeRange
Min
=
"0"
Max
=
"32"
TickBackground
=
"{StaticResource ControlGreen}"
Background
=
"{StaticResource BackgroundBlack}"
StartWidth
=
"0.15"
EndWidth
=
"0.15"
/>
<
telerik:GaugeRange
Min
=
"34"
Max
=
"65"
TickBackground
=
"{StaticResource ControlGreen}"
Background
=
"{StaticResource ControlGreen}"
StartWidth
=
"0.15"
EndWidth
=
"0.15"
/>
<
telerik:GaugeRange
Min
=
"67"
Max
=
"100"
TickBackground
=
"{StaticResource ControlGreen}"
Background
=
"{StaticResource BackgroundBlack}"
StartWidth
=
"0.15"
EndWidth
=
"0.15"
/>
</
telerik:RadialScale.Ranges
>
<
telerik:RadialScale.Indicators
>
<
telerik:Needle
IsAnimated
=
"True"
Value
=
"91"
Style
=
"{StaticResource GaugeNeedleStyle}"
/>
</
telerik:RadialScale.Indicators
>
</
telerik:RadialScale
>
</
telerik:RadSemicircleNorthGauge
>
My workaround:
I added the ranges to the Gauge in code behind.
public
partial
class
TestView : UserControl
{
public
TestView ()
{
InitializeComponent();
this
.Loaded +=
new
RoutedEventHandler(TestView _Loaded);
}
void
TestView _Loaded(
object
sender, RoutedEventArgs e)
{
this
.Dispatcher.BeginInvoke(() =>
{
this
.GaugeRadialScale.Ranges.Add(
new
GaugeRange() { Min = 0, Max = 32, Background =
new
SolidColorBrush(Colors.Magenta), StartWidth = 0.15, EndWidth = 0.15, TickBackground =
new
SolidColorBrush(Colors.Blue) });
this
.GaugeRadialScale.Ranges.Add(
new
GaugeRange() { Min = 34, Max = 65, Background =
new
SolidColorBrush(Colors.Magenta), StartWidth = 0.15, EndWidth = 0.15, TickBackground =
new
SolidColorBrush(Colors.Blue) });
this
.GaugeRadialScale.Ranges.Add(
new
GaugeRange() { Min = 67, Max = 100, Background =
new
SolidColorBrush(Colors.Magenta), StartWidth = 0.15, EndWidth = 0.15, TickBackground =
new
SolidColorBrush(Colors.Blue) });
});
}
}
Below is a link to a sample project that will give the error.
http://www.burgundi.com/wp-content/uploads/2012/03/CaliburnGaugeTest.zip
Is this something that can be resolved since i don´t want any code in my code behind?
Regards,
Sebastian