TrackBall Info Template Decimal Places

4 posts, 1 answers
  1. Gareth
    Gareth avatar
    14 posts
    Member since:
    Oct 2015

    Posted 07 Jan Link to this post

    I'm trying to format the String output for my Series Trackball so that it only shows 2 decimal places.  The code I have at the moment for my Template is as follows:

    <telerik:RadCartesianChart.Resources>
    <sys:String x:Key="CategoryFormat">Date: {0}</sys:String>
    <sys:String x:Key="ValueFormat">Value: {0:n2}</sys:String>
                                                     
    <DataTemplate x:Key="seriesTrackBallInfoTemplate">
          <StackPanel Orientation="Vertical">
           <TextBlock Text="{Binding Path=MeasurementData.Category, StringFormat={StaticResource CategoryFormat}}" />
            <TextBlock Text="{Binding Path=MeasurementData.Value, StringFormat={StaticResource ValueFormat}}" />
            </StackPanel>
    </DataTemplate>
     </telerik:RadCartesianChart.Resources>

    The type of MeasurementData.Value is Double.

    I've tried various approaches and nothing seems to work.

    Any suggestions?

     

     

  2. Gareth
    Gareth avatar
    14 posts
    Member since:
    Oct 2015

    Posted 07 Jan in reply to Gareth Link to this post

    Nevermind.  Used a Double to String Converter and put my formatter settings in there.
  3. UI for WPF is Visual Studio 2017 Ready
  4. Gareth
    Gareth avatar
    14 posts
    Member since:
    Oct 2015

    Posted 07 Jan in reply to Gareth Link to this post

    Turns out that didn't work either. Is it possible to edit the DisplayContent of the TrackballInfoTemplate to remove the huge amounts of decimal points?
  5. Answer
    Ivan
    Admin
    Ivan avatar
    44 posts

    Posted 11 Jan Link to this post

    Hello Gareth,

    As we look at your code and the picture it seems that the TrackballInfoTemplate is not applied and the series is using its default template. 

    Also, keep in mind that the DataContext passed in the template is not the view model of the data point, but an object of type DataPointInfo. So, in order to get your view model you can use the following syntax:
    <TextBlock Text="{Binding Path=DataPoint.DataItem.Value}" />
    You can also take a look at the attached project where this approach is demonstrated.
     
    Please let us know if this solution works for you.

    Regards,
    Ivan
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top