Completed
Last Updated: 12 Nov 2024 08:17 by ADMIN
Release Telerik UI for WPF 2024.4.1111 (2024 Q4)
Ronald
Created on: 09 Oct 2024 14:35
Category: Diagram
Type: Bug Report
0
Diagrams: Save then load of diagram items makes new unique ids for every item in the XML

This is a regressiion issue in the 2024.3.924 release of Telerik UI for WPF.
Save and load of the saved XML should result of the same item IDs for every RadDiagramItem (shapes, connections).

To work this around, you can create a custom SerializationService and override its DeserializeItems method, where you can change the "makeUnique" parameter.

The issue manifests also when doing drag/drop from the RadDiagramToolBox or any other custom drag drop implementation that uses the DiagramDropInfo class (which is automatically handled by the RadDiagram's drop internal code). In this case the custom service approach won't work because the drag/drop deserialization works with a separate instance of SerializationService (SerializationService.Default) which cannot be changed. In this case, you can subscribe RadDiagram to the DragDropManaged.Drop event and manually call the SerializationService.Default.DeserializeItems method.

 public class CustomSerializationService : SerializationService
 {
     public CustomSerializationService(IGraphInternal graph) : base(graph)
     {
     }

     public override IEnumerable<IDiagramItem> DeserializeItems(SerializationInfo serializationInfo, bool makeUnique = false)
     {
         makeUnique = false;
         return base.DeserializeItems(serializationInfo, makeUnique);
     }
 }

 public MainWindow()
 {
     InitializeComponent();

     this.diagram.ServiceLocator.Register<ISerializationService>(new CustomSerializationService(this.diagram));

     DragDropManager.AddDropHandler(this.diagram, OnDiagramDrop);
 }

 private void OnDiagramDrop(object sender, Telerik.Windows.DragDrop.DragEventArgs e)
 {
     var data = DragDropPayloadManager.GetDataFromObject(e.Data, typeof(DiagramDropInfo).Name);
     if (data is DiagramDropInfo)
     {
         SerializationService.Default.DeserializeItems(((DiagramDropInfo)data).Info, false);
     }
 }

0 comments