Events in WPF Diagram (SfDiagram)

12 Jun 20241 minute to read

The AnnotationChanged event will notify the annotation related actions and value changes. The AnnotationChangedEventArgs class is used to get or set the entire annotation related properties and their values.

//Register the AnnotationChanged event
(diagram.Info as IGraphInfo).AnnotationChanged += Diagram_AnnotationChanged;

//Method to show message box when annotation is changed
private void Diagram_AnnotationChanged(object sender, ChangeEventArgs<object, AnnotationChangedEventArgs> args)
{
    //When annotation is resized
    if (args.NewValue.AnnotationInteractionState == AnnotationInteractionState.Resized)
    {
        MessageBox.Show("Annotation has been resized!");
    }

    //When annotation is resized
    if (args.NewValue.AnnotationInteractionState == AnnotationInteractionState.Rotated)
    {
        MessageBox.Show("Annotation has been rotated!");
    }

    //When annotation is resized
    if (args.NewValue.AnnotationInteractionState == AnnotationInteractionState.Edited)
    {
        MessageBox.Show("Annotation has been edited!");
    }
}

See Also

How to add or remove annotation constraints?

How to localize the annotations?

How to restrict annotation editing by double-clicking the node or connector?