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

How to programmically update chart inside HubSection?

1 Answer 47 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.
Melicaster
Top achievements
Rank 1
Melicaster asked on 17 Jan 2015, 04:48 PM
I has been reading http://www.telerik.com/help/windows-8-xaml/radchart-series-doughnutseries.html and has successfully created the scenario based on the tutorial.

However, I need the chart to work inside HubSection. The snippet of the my XAML as below:
<HubSection Header="HubSection 2">
                <DataTemplate>
                    <Grid>
                        <telerik:RadPieChart  x:Name="mychart" Width="300" Height="300" ClipToBounds="False" PaletteName="DefaultDark">
                            <telerik:DoughnutSeries ShowLabels="True">
                                <telerik:DoughnutSeries.ValueBinding>
                                    <telerik:PropertyNameDataPointBinding PropertyName="Value"/>
                                </telerik:DoughnutSeries.ValueBinding>
                            </telerik:DoughnutSeries>
                        </telerik:RadPieChart>
                    </Grid>
                </DataTemplate>
            </HubSection>

I need to periodically update the chart. So I couldn't use loaded. I only can search the control manually using VisualTreeHelper. How do I create the Donut Chart control manually? I know that we can create an control using below snippet:
private TextBlock NoArticlesTextBlock;

I search the child using snippet like below:
static DependencyObject FindChildByName(DependencyObject from, string name)
        {
            int count = VisualTreeHelper.GetChildrenCount(from);
 
            for (int i = 0; i < count; i++)
            {
                var child = VisualTreeHelper.GetChild(from, i);
                if (child is FrameworkElement && ((FrameworkElement)child).Name == name)
                    return child;
 
                var result = FindChildByName(child, name);
                if (result != null)
                    return result;
            }
 
            return null;
        }

Please advise. Thank you.

1 Answer, 1 is accepted

Sort by
0
Ves
Telerik team
answered on 21 Jan 2015, 08:06 AM
Hi,

This question is valid for any control and it is not specific for our chart. You already have one solution and an alternative would be to wrap the chart within a user control, where you will have access to the chart.

Best regards,
Ves
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Chart
Asked by
Melicaster
Top achievements
Rank 1
Answers by
Ves
Telerik team
Share this question
or