This is a migrated thread and some comments may be shown as answers.

ConnectionPoints in MVVM Pattern

1 Answer 138 Views
Diagram
This is a migrated thread and some comments may be shown as answers.
Christian
Top achievements
Rank 1
Christian asked on 07 Mar 2021, 12:49 PM

Hi,

we have a MVVM Scenario, where changes in the Raddiagram need to be reflected in the underlying viewmodel.

For shapes and connections that is easy, because we can implement IObservableGraphSource and contruct the necessary objects. ConnectionPoints however seem tricky. While moving a point triggers a ConnectionManipulationEvent, adding or deleting points via CTRL+Click apparently do not trigger this event?

I do realize that, even though it only exposes IList, ConnectionPoints is actually an ObeservableCollection and with this knowledge I can hack my way around this, but then adding a new Point causes this collection to reset and add all points one by one again, which is also not really what I want to do in my Viewmodel.

Is there an easier way to reflect these changes (adding/removing ConnectionPoints) back into the viewmodel properly, without having to create a custom ConnectionManipulationTool wihich notifies on such changes?

Thanks in advance!

Regards

1 Answer, 1 is accepted

Sort by
0
Martin Ivanov
Telerik team
answered on 10 Mar 2021, 12:13 PM

Hello Christian,

Currently, there are two feature requests that will be useful in this situation.

There is a comment in the second feature request describing a couple of possible options that allows listening of add/remove connection points. The other approach is the one mentioned by you where you use the CollectionChanged event of the ConnectionPoints which is an ObservableCollection<Point>. Note that the CollectionChanged is always fired with Reset action because on each add/remove connection point the ConnectionPoints collection is cleared and re-populated. This happens in order to implement the undo/redo functionality of the diagram.

I hope this information helps. If you have other questions, please let me know.

Regards,
Martin Ivanov
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.

Tags
Diagram
Asked by
Christian
Top achievements
Rank 1
Answers by
Martin Ivanov
Telerik team
Share this question
or