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

0
0

Hello,

I have created a composite annotation consisting of a Box and a Text Annotations and I need the text to be editable.
I set the TextAnnotation.CanEditText to true, but it doesn’t seem to work. How can I achieve that?

Also, is it possible to allow moving (by dragging) only the Text Annotation inside the composite?

Version
Trial
  • You must to post comments
0
0

Hello Ursu,

Thanks for your inquiry.

The desired behavior is not supported out of the box. However, there is a workaround from one of SciChart users. You should override the AttachAnnotation(..) method in CompositeAnnotation class in this way:

protected virtual void AttachAnnotation(IAnnotation item)

{
item.Services = Services;
item.ParentSurface = ParentSurface;
item.IsAttached = true;

item.OnAttached();

// Optional bindings here
var annotation = item as AnnotationBase;
if (annotation != null)
{
    var xAxisIdbinding = new Binding
    {
        Source = this,
        Path = new PropertyPath(XAxisIdProperty)
    };
    annotation.SetBinding(XAxisIdProperty, xAxisIdbinding);

    var yAxisIdbinding = new Binding
    {
        Source = this,
        Path = new PropertyPath(YAxisIdProperty)
    };
    annotation.SetBinding(YAxisIdProperty, yAxisIdbinding);

    var isHiddenBinding = new Binding
    {
        Source = this,
        Path = new PropertyPath(IsHiddenProperty)
    };
    annotation.SetBinding(IsHiddenProperty, isHiddenBinding);
}

}

Besides, you have to set both properties IsEditable and CanSditText to “True”.

Please try this and let me know if everything works as expected.

Best Regards,
Yuriy

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.