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

Custom connection and MVVM

4 Answers 228 Views
Diagram
This is a migrated thread and some comments may be shown as answers.
Sarper
Top achievements
Rank 2
Sarper asked on 13 Oct 2012, 06:39 PM
Hİ,

I am using a custom connection for a special purpose and want to use MVVM. But I do not know how to create custom connection instance when using MVVM. Because it needs to be created and added to the diagram instance not the graphsource. Graphsource have AddLink method but it do not take RadDiagramConnection. Can you help me to find a way to use that Custom Connection class?
Thank you,
Sarper

4 Answers, 1 is accepted

Sort by
0
Accepted
Miro Miroslavov
Telerik team
answered on 16 Oct 2012, 08:36 AM
Hi Sarper,

 You should inherit the RadDiagram and override the GetConnectionContainerForItemOverride(object item) method. This method creates the actual visual connection (usually RadDiagramConnection) for every ILink object in your ViewModel, so if you override it and change the code to the following, it should work:

protected overrideIConnection GetConnectionContainerForItemOverride(object item)
       {
           return new MyCustomConnection();
       }
Let us know if this works for you.

Regards,
Miro Miroslavov
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Sarper
Top achievements
Rank 2
answered on 16 Oct 2012, 06:30 PM
Hi Miro Miroslavov, 

I create custom diagram class and add that override method and.. It worked like a charm... I appreciated for your help really.
I think that RadDiagram Framework is really good and flexible for all purposes. It has many features to customize and configure..
Thank you.

All the best,
Sarper 
0
Sammy
Top achievements
Rank 1
answered on 24 Jul 2014, 04:53 AM
Hello,

I have a further problem. If I drag a connection from a connector of a shape to a connector of another shape this override method also executed but the graphsource is not updated and the datacontext of the connection is not my custom modelview class. How can I make the diagram to update its graphsource with my custom modelview classes?

Thanks,
0
Pavel R. Pavlov
Telerik team
answered on 28 Jul 2014, 12:06 PM
Hello,

Could you please take a look at the attached project? It demonstrates how the RadDiagram should be used when you need to create derived connections and shapes in MVVM scenario. 

Do not hesitate to ask if you need any further assistance.

Regards,
Pavel R. Pavlov
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
Tags
Diagram
Asked by
Sarper
Top achievements
Rank 2
Answers by
Miro Miroslavov
Telerik team
Sarper
Top achievements
Rank 2
Sammy
Top achievements
Rank 1
Pavel R. Pavlov
Telerik team
Share this question
or