SciChart® the market leader in Fast WPF Charts, WPF 3D Charts, iOS Chart, Android Chart and JavaScript Chart Components


I want to plot line chart on BoxAnnotation, so that BoxAnnotion become as a container.
i.e dataSeries.Append(100, 100);
dataSeries.Append(200, 150;
on BoxAnnotation
Please have a lool into the picture.

  • You must to post comments

Hi there,

If I understand correctly, what you want to achieve is to have a chart inside a BoxAnnotation, so you can drag this around the underlying chart. Is that correct?

If so, this could be achieved by re-templating the BoxAnnotation ControlTemplate to hold another chart.

The template for BoxAnnotation is quite simple. It specifies a Border with templateBindings to BorderBrush, BorderThickness, Background. Try this, for instance:

      <!-- Retemplate the BoxAnnotation to be anything you want -->
      <ControlTemplate TargetType="{x:Type BoxAnnotation}">
         <Border x:Name="PART_BoxAnnotationRoot" BorderBrush="{TemplateBinding BorderBrush}" Background="{TemplateBinding Background}" BorderThickness="{TemplateBinding BorderThickness}">
            <!-- Place a SciChartSurface inside the BoxAnnotation Border -->
                   <!-- Set DataContext of annotation equal to a ViewModel so you can bind to DataSeries property -->
                   <s:FastLineRenderableSeries DataSeries="{Binding DataSeries}"/>

I’ve not tested the above code but it conveys the concept. You can template the BoxAnnotation to be anything you want, even placing a chart inside it. Just beware that you must set the DataContext of your BoxAnnotation equal to something (like a viewmodel) so the inner ScichartSurface can see this datacontext to bind to DataSeries.

Let me know if it helps, and post pictures of the result if you achieve it!

Best regards,

    Hi Andrew,Thanks for your quick response, I am trying to do the requirement according to the given solution but I am getting "Unable to Apply the Control Template. PART_BoxAnnotationRoot is missing or of the wrong type" error. As it given for xaml file but I need to implement in viewModel,Plz help
    Hi Andrew, Can I get the same xaml code as a C# code ,So That I can test in Viewmodel.I hope it will work.
  • Andrew Burnett-Thompson
    Oh sorry, I have edited my code in answer. Try adding x:Name="PART_BoxAnnotationRoot" to the Border. To do the same in Code-behind would be nearly impossible, I would strongly recommend altering control templates in Xaml! However, if you wanted to go this route you can use this technique:
    Thak you Andrew,Yes I had added the same & It was working in xaml code, But I have to make it dynymic at ViewModel side,let me try the other solution.
  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.