This is a migrated thread and some comments may be shown as answers.

FindName fails

1 Answer 71 Views
Chart
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
ManniAT
Top achievements
Rank 2
ManniAT asked on 27 Mar 2012, 09:54 PM
Hi,

I have two projects - one for SL5 and one for WP7,
They share the same XAML and in the gs file I find similar code.
The problem comes from the following axis;
<telerikChart:RadCartesianChart.HorizontalAxis>
                <telerikChart:DateTimeContinuousAxis x:Name="xAxis"
                                            MajorStepUnit="Day"
                                            LabelInterval="1"
                                            LabelFormat="dd.MM"                                                                                                    
                                            PlotMode="OnTicks" LabelFitMode="Rotate" />
                <!--    Minimum="{Binding XMinimum}"   
                Maximum="{Binding XMaximum}"
                MajorStep="{Binding XMajorStep}"
                -->
            </telerikChart:RadCartesianChart.HorizontalAxis>
            <telerikChart:RadCartesianChart.VerticalAxis>
                <telerikChart:LinearAxis x:Name="yAxis" Minimum="{Binding YMinimum}" Maximum="{Binding YMaximum}" />
            </telerikChart:RadCartesianChart.VerticalAxis>
This results in the following code in WP7:
this.rcData = ((Telerik.Windows.Controls.RadCartesianChart)(this.FindName("rcData")));
    this.xAxis = ((Telerik.Windows.Controls.DateTimeContinuousAxis)(this.FindName("xAxis")));
    this.yAxis = ((Telerik.Windows.Controls.LinearAxis)(this.FindName("yAxis")));
In SL it is:
this.rcData = ((Telerik.Windows.Controls.RadCartesianChart)(this.FindName("rcData")));
   this.xAxis = ((Telerik.Windows.Controls.ChartView.DateTimeContinuousAxis)(this.FindName("xAxis")));
   this.yAxis = ((Telerik.Windows.Controls.ChartView.LinearAxis)(this.FindName("yAxis")));
While the namespace is different - the rest is almost the same.
But in WP7 the code fails (xAxis / yAxis is null) while this works in SL5.

Is this a fault of your controls or a problem of WP7?

I need access to the axes since some important properties are not bindable.
(see this post about the issue http://www.telerik.com/community/forums/windows-phone/chart/properties-not-bindable.aspx)
I have a workaround which works for SL as well as for WP7 (I share the same code for both projects) but I just want to know why this doesn't work in WP7.

Manfred

1 Answer, 1 is accepted

Sort by
0
Accepted
Victor
Telerik team
answered on 29 Mar 2012, 03:05 PM
Hi Manfred,

Thank you for contacting us.

While developing the control suite for Windows Phone we noticed some really awkward behavior that is related to the xaml parsing. For unknown reasons, the version of Silverlight for WP7 parses xaml differently which results in null auto-generated fields during run-time. This help article describes the same problem for the chart series but as it turns out it also applies to the axes.
I am afraid that there isn't anything we can do on our side. You need to cast the HorizontalAxis and VerticalAxis properties to the appropriate type.

Thank you for understanding.

Kind regards,
Victor
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
Tags
Chart
Asked by
ManniAT
Top achievements
Rank 2
Answers by
Victor
Telerik team
Share this question
or