Articles in this section

How to preserve style for the newly created objects at runtime?

In UWP Diagram, we do not have support to apply common style in XAML for diagramming elements. So, the sample level code is expected to apply style for the newly created objects during runtime interactions like duplicate, drag drop, and drawing tools.

The following are the two ways to achieve this common style.

  1. By creating the custom class for diagramming elements.
  2. By using the ItemAdded event

By creating the custom class for diagramming elements

 

Custom class for diagramming elements can be created by deriving it from its respective view model or implementing the respective interfaces. You can assign the default style for Node, Connector, Port and Annotation in the constructor in respective custom classes.

Refer to the following sample for the diagramming elements default style with custom class.

Sample link: Preserve_Style_CustomClass

By using the ItemAdded event

 

Diagram have support to notify when elements get added in the Diagram by using the ItemAdded event. With the assistance of the ItemAddedEventArgs, validate the elements and assign a default style.

Refer to the following sample for the diagramming elements default style with an item added event.

Sample link: Preserve_Style_Event

Conclusion

I hope you enjoyed learning about how to preserve style for the newly created objects at runtime.

You can refer to our UWP Diagram’s feature tour page to know about its other groundbreaking feature representations. You can also explore our UWP Diagram documentation to understand how to present and manipulate data.

For current customers, you can check out our UWP components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our UWP Diagram and other UWP Diagram components.

If you have any queries or require clarifications, please let us know in comments below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!

 

 

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