Gliding Connector exception when replacing view model

4 posts, 1 answers
  1. Michael
    Michael avatar
    26 posts
    Member since:
    Oct 2014

    Posted 05 Nov 2014 Link to this post

    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     
  2. Answer
    Pavel R. Pavlov
    Admin
    Pavel R. Pavlov avatar
    1182 posts

    Posted 10 Nov 2014 Link to this post

    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.

     
  3. DevCraft banner
  4. Michael
    Michael avatar
    26 posts
    Member since:
    Oct 2014

    Posted 11 Nov 2014 in reply to Pavel R. Pavlov Link to this post

    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!
  5. Michael
    Michael avatar
    26 posts
    Member since:
    Oct 2014

    Posted 17 Nov 2014 Link to this post

    The reference example code you provided helped to resolve the issue on my side.

    Thanks again.
Back to Top