Using DataItem in TrackBallInfoTemplate

3 posts, 0 answers
  1. Robin
    Robin avatar
    3 posts
    Member since:
    Jun 2014

    Posted 05 Jun 2014 Link to this post


    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:
                 <StackPanel Orientation="Horizontal">
                   <TextBlock Text="{Binding DataPoint.Value}" FontWeight="Bold" />
                   <TextBlock Text=":" FontWeight="Bold" />
                   <TextBlock Text="{Binding DataPoint.DataItem.Name}" FontWeight="Bold" />     

    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".


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

    Thanks in advance,

  2. Petar Marchev
    Petar Marchev avatar
    996 posts

    Posted 09 Jun 2014 Link to this post

    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" />

    Petar Marchev
    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.
  3. Robin
    Robin avatar
    3 posts
    Member since:
    Jun 2014

    Posted 11 Jun 2014 in reply to Petar Marchev Link to this post

    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"           

    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,

Back to Top