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

Gliding Connector exception when replacing view model

3 Answers 55 Views
Diagram
This is a migrated thread and some comments may be shown as answers.
Michael
Top achievements
Rank 1
Michael asked on 05 Nov 2014, 06:28 PM
Hello,

I have a view model structure inheriting from ObservableGraphSourceBase<T, LinkViewMOdelBase<T>> and the loading and displaying of the shapes and connectors (with respect to the items and links) works very well.  UseGlidingConnector = true for the shapes.  But when I try and load a new view model structure to replace the existing one, an exception is being thrown with the text:

The gliding connector cannot be removed because connections are attached to it.

I have tried the following: calling Clear() on the view model structure, then setting it to null, then assigning it to a new view model.  I've also tried iterating through the connections and clearing the connections before assigning a new viewmodel like so, but the exception still occurred:

public void ClearConnections()
{
  foreach (var link in diagram.Connections)
  {
    diagram.RemoveConnection(link, false);
  }
 
  RadDiagramShape dShape = null;
  foreach (var shape in diagram.Shapes)
  {
    dShape = shape as RadDiagramShape;
    dShape.Connectors.Clear();
    dShape.UseDefaultConnectors = true;
  }
}



Can I load a new view-model hierarchy into a diagram?  If so can you advise on what approach to take?

Much thanks,

Mike     

3 Answers, 1 is accepted

Sort by
0
Accepted
Pavel R. Pavlov
Telerik team
answered on 10 Nov 2014, 08:41 AM
Hello Mike,

I tried to reproduce the issue on our side and it seems that the code works as expected. Could you please take a look at the attached project and let me know if I missed something? Please note that I tried setting the UseGlidingConnector property in XAML and CodeBehind on button click. In both scenarios I was able to change the underlying source. I used our latest official release for the test.

Regards,
Pavel R. Pavlov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Michael
Top achievements
Rank 1
answered on 11 Nov 2014, 04:46 PM
Pavel,

Thank you for your quick response.  I need to correlate the example you provided with the issues I am having and will post back here.

Thanks!
0
Michael
Top achievements
Rank 1
answered on 17 Nov 2014, 03:05 PM
The reference example code you provided helped to resolve the issue on my side.

Thanks again.
Tags
Diagram
Asked by
Michael
Top achievements
Rank 1
Answers by
Pavel R. Pavlov
Telerik team
Michael
Top achievements
Rank 1
Share this question
or