How do I make a loaded (pre-defined) diagram interactive with commands, etc?

1 Answer 60 Views
Diagram
The Nimble Coder
Top achievements
Rank 2
Iron
The Nimble Coder asked on 15 Aug 2022, 09:45 AM | edited on 15 Aug 2022, 09:46 AM

Hello, 

Using the DiagramDesignToolBox_WPF project diagram control (from Telerik's github) samples, I created a basic diagram. See attached.

Once the diagram is loaded, is it possible to associate commands such as click, be able to update the diagram object's background color, be able to update the diagram object's text, etc.?

Thanks,

Mark

One last question:

My Telerik subscription provides me with X support tickets per year but I can't find where to create a new support ticket. I see my past tickets that I've created but no where can I start a new one. How can I start a 'priority' question that is associated with my paid Telerik subscription?

1 Answer, 1 is accepted

Sort by
0
Dilyan Traykov
Telerik team
answered on 16 Aug 2022, 08:44 AM

Hello Mark,

Thank you for the provided XML declaration.

Generally speaking, you can handle the ShapeDeserialized event of the control and apply any additional logic you require there:

        private void diagram_ShapeDeserialized(object sender, ShapeSerializationRoutedEventArgs e)
        {
			var shape = e.Shape as RadDiagramShape;
            shape.MouseLeftButtonDown += Shape_MouseLeftButtonDown;
			shape.Background = Brushes.Lavender;
        }

        private void Shape_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
			MessageBox.Show("Shape clicked!");
        }

Can you please give this a try and let me know if this works for you?

As for your inquiry about posting a new support ticket, this can be done from the Support Center by clicking on the Contact Us link:

If you do not see this link, please let us know and we will gladly investigate why this section is not visible to you.

Regards,
Dilyan Traykov
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

The Nimble Coder
Top achievements
Rank 2
Iron
commented on 16 Aug 2022, 10:01 AM

Hello Dilyan, 

Fantastic! Does the ShapeDeserialized event fire for each shape on the diagram when it is deserialized?

Also, if I wanted to utilize MVVM for this - what does that approach look like?

Thanks and I appreciate the help!

-Mark

Dilyan Traykov
Telerik team
commented on 17 Aug 2022, 08:34 AM

Hello Mark,

Indeed, the ShapeDeserialized event is fired for each individual shape.

When you need to perform this scenario in a data-bound (MVVM) scenario, you need to implement the DeserializeNode method of the ISerializableGraphSource interface. This has been documented in the following article: Serialize a Databound Diagram.

Please let me know if you find this information useful.

The Nimble Coder
Top achievements
Rank 2
Iron
commented on 19 Aug 2022, 12:22 PM

Thanks Dilyan!

Can you point to a full (working) example of how to fully implement this using MVVM as discussed in the link you sent above?

Thanks again.

-Mark

Dilyan Traykov
Telerik team
commented on 24 Aug 2022, 08:14 AM

Hello Mark,

We do have a working example titled "MVVM" in our GitHub repository. The example can also be viewed with our SDK Samples Browser.

For your convenience, I'm also attaching the project to my reply. Please have a look and let me know if you find it helpful.

Tags
Diagram
Asked by
The Nimble Coder
Top achievements
Rank 2
Iron
Answers by
Dilyan Traykov
Telerik team
Share this question
or