We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to use the property grid in the WPF Diagram (SfDiagram)?

Platform: WPF |
Control: SfDiagram
Tags: propertygrid

The PropertyGrid control can be used to show the properties of the selected object and able to change the values dynamically. The properties values will be updated dynamically based on the selected objects using the events of the WPF Diagram (SfDiagram) control.

C#

public partial class MainWindow : Window
{ 
  public MainWindow()
  {
    InitializeComponent();
    SfDiagram diagram = new SfDiagram();
    (diagram.Info as IGraphInfo).ItemSelectedEvent += MainWindow_ItemSelectedEvent;
    (diagram.Info as IGraphInfo).AnnotationChanged += MainWindow_AnnotationChanged;
  }
 
  private void MainWindow_AnnotationChanged(object sender, ChangeEventArgs<object, AnnotationChangedEventArgs> args)
  {
    if (args.Item is IAnnotation)
    {
      propertyGrid1.SelectedObject = args.Item;
    }
  }
        
  void MainWindow_ItemSelectedEvent(object sender, DiagramEventArgs args)
  {
    if (args.Item is INode)
    {
      propertyGrid1.SelectedObject = args.Item;
    }
    else if (args.Item is IConnector)
    {
      propertyGrid1.SelectedObject = args.Item;
    }
  }
}

View sample in GitHub.

2X faster development

The ultimate WPF UI toolkit to boost your development speed.
ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile