Setting Plot Band Annotations from code behind

2 posts, 0 answers
  1. Terry
    Terry avatar
    19 posts
    Member since:
    Feb 2014

    Posted 02 Mar 2014 Link to this post

    Is there a way to set plot band annotations dynamically from C# code behind instead of from XAML?

    The examples demonstrate the XAML approach, for instance, 
    <telerik:CartesianPlotBandAnnotation Axis="{Binding ElementName=chart3HAxis}" To="3/2/2014" From="3/4/2014" />

    but how to accomplish the sample thing using code behind, dynamically. 
  2. Terry
    Terry avatar
    19 posts
    Member since:
    Feb 2014

    Posted 02 Mar 2014 in reply to Terry Link to this post

    Think I figured it out. For those interested, you can do it as follows:

    //horizontal example with dates  X is a DateTime object
     chart3.Annotations.Add(new CartesianPlotBandAnnotation { Label = "plot region", From = chartData[2].X, To = chartData[5].X, Axis = chart3.HorizontalAxis });
     
    //vertically Y is a double or just a numeric range like From=3 To=7
    chart3.Annotations.Add(new CartesianPlotBandAnnotation { Label = "plot band annotations", From = 0, To = chartData[3].Y, Axis = chart3.VerticalAxis });

  3. UI for WPF is Visual Studio 2017 Ready
Back to Top