Articles in this section
Category / Section

How to programmatically show or hide annotations in WPF Diagram (SfDiagram)?

1 min read

WPF Diagram (SfDiagram) support to customize the Visibility of Annotation. This can be achieved by using custom class from AnnotationEditorViewModel and ViewTemplate property of Annotation. We have provided code example, sample and screenshots to represent this.

C#

//Annotation collection
node.Annotations = new ObservableCollection<AnnotationEditorViewModel>
{
  new Annotation()
  {
    Content="node",
    //set visibility as Hidden|Visible|Collapsed to Annotation content
    Visibility=Visibility.Collapsed,
    ViewTemplate=this.Resources["viewtemplate"] as DataTemplate
  }
};

 

WPF Diagram displays Annotation

Hiding Annotation in WPF Diagram

 

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied