FindName fails

2 posts, 1 answers
  1. ManniAT
    ManniAT avatar
    877 posts
    Member since:
    Nov 2003

    Posted 27 Mar 2012 Link to this post

    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

  2. Answer
    Victor
    Admin
    Victor avatar
    1351 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,
    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 >>
  3. DevCraft banner
Back to Top