Events in WPF Diagram (SfDiagram)

29 Nov 20241 minute to read

Annotation Changed Event

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!");
    }
}

Selection Events:

View Sample in GitHub

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?