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

[Solved] Series is null at runtime

1 Answer 77 Views
Chart for XAML
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Mikhail
Top achievements
Rank 1
Mikhail asked on 18 Aug 2012, 09:30 PM
Hi,

This isn't a particularly major problem, but its annoying. If I have, roughly:

<PieChart x:Name="ThePieChart">
<PieSeries x:Name="ThePieSeries"/>
</PieChart>

Then, in code, "ThePieSeries" will always be null, for some reason. I can still access the series by using "ThePieChart.Series[x]", but this notation gets annoying when I have to use it a lot.

Best,
Mike

1 Answer, 1 is accepted

Sort by
0
Tsvyatko
Telerik team
answered on 20 Aug 2012, 11:22 AM
Hello Mikhail,

 We have noticed this behavior. It is caused by the fact that in WinRT all named properties in page are resolved in its InititializeComponent (rather in IComponentConnector.Connect in WPF). Thus, it will resolve only the elements that are parced added in the visual tree at initialize time. 

With our current infrastructure our chart requires at least applying it template to insert its series and axis in the correct place of the visual tree, leaving its page properties empty. Nevertheless, we are looking for an option to support this scenario.

Currently, I can suggest the following workaround:

public MainPage()
{
    this.InitializeComponent();
 
    this.Loaded += MainPage_Loaded;
}
 
void MainPage_Loaded(object sender, RoutedEventArgs e)
{
    ThePieSeries = (Telerik.UI.Xaml.Controls.BarSeries)this.FindName("ThePieSeries");
}

Greetings,
Tsvyatko
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
Chart for XAML
Asked by
Mikhail
Top achievements
Rank 1
Answers by
Tsvyatko
Telerik team
Share this question
or