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 } };