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

Using DataItem in TrackBallInfoTemplate

2 Answers 357 Views
ChartView
This is a migrated thread and some comments may be shown as answers.
Robin
Top achievements
Rank 1
Robin asked on 05 Jun 2014, 12:38 PM
Hi,

I have been reading the resources and forum posts but I can't seem to be able to bind a TextBlock in my TrackBallInfoTemplate to a field on the DataItem object.

The following is the TrackBallInfoTemplate:
    <chartView:BarSeries.TrackBallInfoTemplate>
           <DataTemplate>
             <StackPanel Orientation="Horizontal">
               <TextBlock Text="{Binding DataPoint.Value}" FontWeight="Bold" />
               <TextBlock Text=":" FontWeight="Bold" />
               <TextBlock Text="{Binding DataPoint.DataItem.Name}" FontWeight="Bold" />     
</StackPanel>
           </DataTemplate>
         </chartView:BarSeries.TrackBallInfoTemplate>

The following is a definition of the class containing the data which is used to display the bar chart:
public class CategoryData
{
  public string Name { get; set; }
  public double Value { get; set; }
  public string Category { get; set; }
}

On the Bar Series definition in XAML the CategoryBinding is set to the "Category" field and the ValueBinding is set to "Value".

The graph displays but only the DataPoint.Value field is bound in the TrackBallInfo template. The other "Name" field does not appear.

According to the UI WPF API doc the "DataItem" field should contain "the original data item".

Ref:
http://www.telerik.com/help/wpf/p_telerik_windows_controls_charting_datapoint_dataitem.html

Am I missing something fundamental here? I am using Telerik.Windows.Controls.Chart version 2013.3.1204.40.

Thanks in advance,

Rob

2 Answers, 1 is accepted

Sort by
0
Petar Marchev
Telerik team
answered on 09 Jun 2014, 07:29 AM
Hi Robin,

You can check our online examples and sdk samples where you will find the track ball demonstrated and customized. The DataContext of the template is the actual DataPoint, so you can delete the DataPoint. prefix:
<StackPanel Orientation="Horizontal">
 <TextBlock Text="{Binding Value}" FontWeight="Bold" />

Regards,
Petar Marchev
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
0
Robin
Top achievements
Rank 1
answered on 11 Jun 2014, 06:32 AM
Hi Petar,

Thanks for the response. This helped quite a lot, from the SDK samples I managed to add the following method on TrackInfoUpdated:

<telerik:ChartTrackBallBehavior ShowTrackInfo="True"           
    ShowIntersectionPoints="True"
    TrackInfoUpdated="ChartTrackBallBehavior_TrackInfoUpdated"/>

In this method body I then customized the data in the Track Ball Info box header as in the example.Therefore, my problem is solved.

Kind Regards,

Robin
Tags
ChartView
Asked by
Robin
Top achievements
Rank 1
Answers by
Petar Marchev
Telerik team
Robin
Top achievements
Rank 1
Share this question
or