FindName fails

Thread is closed for posting
2 posts, 1 answers
  1. ManniAT
    ManniAT avatar
    885 posts
    Member since:
    Nov 2003

    Posted 27 Mar 2012 Link to this post


    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:DateTimeContinuousAxis x:Name="xAxis"
                                                PlotMode="OnTicks" LabelFitMode="Rotate" />
                    <!--    Minimum="{Binding XMinimum}"   
                    Maximum="{Binding XMaximum}"
                    MajorStep="{Binding XMajorStep}"
                    <telerikChart:LinearAxis x:Name="yAxis" Minimum="{Binding YMinimum}" Maximum="{Binding YMaximum}" />
    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
    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.


  2. Answer
    Victor avatar
    1358 posts

    Posted 29 Mar 2012 Link to this post

    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,
    the Telerik team
    Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
Back to Top