Binding Annotations collection to some items collection

6 posts, 3 answers
  1. Intecom
    Intecom avatar
    7 posts
    Member since:
    Apr 2013

    Posted 21 Aug 2013 Link to this post

    Hello.

    I need to implement a chart with vertical lines and labels, as I understand it can be implemented using annotations.
    As I can see from examples, it should look lile this:
    <telerik:RadCartesianChart.Annotations>
        <telerik:CartesianGridLineAnnotation Axis="{Binding ElementName=horizontalAxis}" Value="3000" Label="label1">
            <telerik:CartesianGridLineAnnotation.LabelDefinition>
                <telerik:ChartAnnotationLabelDefinition Location="Right" VerticalAlignment="Top" HorizontalOffset="4" DefaultVisualStyle="{StaticResource annotationLabelStyle}">
                </telerik:ChartAnnotationLabelDefinition>
            </telerik:CartesianGridLineAnnotation.LabelDefinition>
        </telerik:CartesianGridLineAnnotation>
        <telerik:CartesianGridLineAnnotation Axis="{Binding ElementName=horizontalAxis}" Value="3200" Label="label2">
            <telerik:CartesianGridLineAnnotation.LabelDefinition>
                <telerik:ChartAnnotationLabelDefinition Location="Right" VerticalAlignment="Top" HorizontalOffset="4" DefaultVisualStyle="{StaticResource annotationLabelStyle}">
                </telerik:ChartAnnotationLabelDefinition>
            </telerik:CartesianGridLineAnnotation.LabelDefinition>
        </telerik:CartesianGridLineAnnotation>
    </telerik:RadCartesianChart.Annotations>

    But information for annotations I get from ViewModel. And I don't see a way how to bind my collections from ViewModel to Annotations collection. Is it possible? I mean something like this:
    <telerik:AnnotationSeries  ItemsSource="{Binding AnnotationsItems}" />

    I found a workaround, to add annotations in a code-behind class of the view:
    foreach (var item in ViewModel.AnnotationsItems)
    {
        Chart1.Annotations.Add(new CartesianGridLineAnnotation { Label = item.Name, Value = item .Coordinate, Axis = Chart1.HorizontalAxis });
    }
    But seems it is not a true way.


    Best regards,
    Dimitr


  2. Answer
    Peshito
    Admin
    Peshito avatar
    497 posts

    Posted 26 Aug 2013 Link to this post

    Hello,

    I am happy that you have found a workaround.

    You are right that the annotations does not have an ItemsSource property. We are aware of this limitation and we will consider an improvement for the future.

    Regards,
    Peshito
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
  3. UI for WPF is Visual Studio 2017 Ready
  4. Wouter
    Wouter avatar
    24 posts
    Member since:
    Jul 2013

    Posted 07 Feb 2014 Link to this post

    Is this something that is evaluated for a possible future release? It would be nice to cut down on code behind.
  5. Answer
    Peshito
    Admin
    Peshito avatar
    497 posts

    Posted 11 Feb 2014 Link to this post

    Hello,

    We have this feature logged in as a feature request. Our latest official release is coming out soon and we will be making our road map for the next one really soon, so this feature will be considered for a possible implementation. I however cannot commit for a specific time frame when or will it be included in the next release. You can comment and vote for the feature in order to increase its priority here.

    Regards,
    Peshito
    Telerik

    Check out the new Telerik Platform - the only modular platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native apps. Register for the free online keynote and webinar to learn more about the Platform on Wednesday, February 12, 2014 at 11:00 a.m. ET (8:00 a.m. PT).

  6. David
    David avatar
    22 posts
    Member since:
    Oct 2012

    Posted 25 Mar 2014 in reply to Peshito Link to this post

    I also really hope that being able to bind to a collection of Annotations is added to the ChartView control library in the near future.  I'd be more than happy to beta test it when this functionality is being developed.
  7. Answer
    Peshito
    Admin
    Peshito avatar
    497 posts

    Posted 26 Mar 2014 Link to this post

    Hello David,

    We haven's scheduled this feature for the upcoming release, however you can vote and rise its priority by doing so, and we will consider it for the upcoming releases. Thank you for your feedback.

    Regards,
    Peshito
    Telerik
     

    Build cross-platform mobile apps using Visual Studio and .NET. Register for the online webinar on 03/27/2014, 11:00AM US ET.. Seats are limited.

     
Back to Top
UI for WPF is Visual Studio 2017 Ready