Pre loader

Annotations in MVVM

Welcome to the SciChart Forums!

  • Please read our Question Asking Guidelines for how to format a good question
  • Some reputation is required to post answers. Get up-voted to avoid the spam filter!
  • We welcome community answers and upvotes. Every Q&A improves SciChart for everyone

WPF Forums | JavaScript Forums | Android Forums | iOS Forums



I have two questions regarding implementing annotations in MVVM:

I’m currently using the MeasureXYAnnotation as demonstrated in an example, and it works well in the code-behind using the CompositeAnnotation class. However, when trying to implement this in MVVM with CompositeAnnotationViewModel, I’ve noticed that the Update method is missing. This omission prevents me from dynamically updating the measures. Is there a way to achieve the same dynamic behavior in MVVM as in code-behind? If so, could you please guide me on how to do it?

My second question is about the BrushAnnotationViewModel, which I’ve seen used in the trade annotation example. Is this ViewModel exclusive to trade charts, or can it be applied to XYCharts as well?

Thank you,
Best Regards

  • Lex
    • Lex
    • 5 months ago
    Hi Nicolas, Thanks for your inquiry. I’ll discuss your questions with our team and will get back to you with an update. I have also noticed there is no file attached to this forum thread. Could you please resend the mentioned sample project? If it wasn’t attached because of the file size, you can delete ‘bin’, ‘obj’, and ‘packages’ folders to reduce the attachment size. Thanks in advance, Lex, SciChart Technical Support Engineer
  • Nicolas MARTINEZ
    The example I mentioned for MeasureXYAnnotation is the official SciChart example.
  • You must to post comments

Hi Nicolas,

We discussed your questions.
We have logged your inquiry regarding CompositeAnnotationViewModel for further investigation and will get back to you as soon as we have an update.

Regarding the Freedraw (Brush) Drawing Tool – you can use it in combination with any chart type available in SciChat.

With best regards,
SciChart Technical Support Engineer

  • You must to post comments

Hello Nicolas,

As for your question, I’ve investigated it and here are some results:
[1] First of all, MeasureXYAnnotation is the custom Annotation that is not part of SciChart library. The purpose of this in our official SciChart.Examples.Demo is to demonstrate the possibility and flexability of creating custom types of annotations based on our existing ones.
This Annotation was made without supporting MvvM, as it wasn’t a requirement for the exact example.

[2] You can try to implement your custom annotation ViewModel and add the Update() logic there
– You can start with this documentation:
*** Note that your annotation(real one not viewModel) should be derived from CompositeAnnotationForMvvm not just CompositeAnnotation(to save all the style bindings for all properties)

public partial class MeasureXyAnnotation : CompositeAnnotationForMvvm

  • The next thing will be to store somehow an object of real one annotation(you can use different ways to achieve this by using Interfaces etc)
  • Then you’ll have to create a method that will call Update()method functionality on ‘a real’ annotation that is stored inside it. Simple method that will get two doubles as a parameters and set’s it accordingly to the X2Y2 props

***** Also you might need to use the AnnotationCreationModifierViewModel
For general idea you can take a look at our TradingAnnotations implementation.

If you still have questions regarding implementation, please ask.

  • You must to post comments
Showing 2 results
Your Answer

Please first to submit.