Layout not working for custom pasted nodes

2 posts, 0 answers
  1. Aakansha
    Aakansha avatar
    20 posts
    Member since:
    Sep 2014

    Posted 17 Nov 2014 Link to this post

    Suppose I copied a sub-tree and pasted on another node. It got pasted. But the bounds it take as 0,0 so all the nodes and its children appear on top of each other.
    To fix this, in my MyCustomPaste() function, I called the same function which telerik has called in mind map diagram demo for layout.

    So my aim is to call any default layout so that nodes get realigned into appropriate position once the pasting of new nodes is done.

    settings.Roots.Add(this.diagram.ContainerGenerator.ContainerFromItem(this.maintViewModel.Source.Items.OfType<object>().ElementAt(0)) as IShape);
    this.diagram.Layout(LayoutType.Tree, settings);
    this.diagram.AutoFit();

    This layout works for the remaining of the nodes which have not been touched by my custom cut and copy function. But the rest of the children of the node which is copied, still come on top of each other. Any fix for this?
  2. Petar Mladenov
    Admin
    Petar Mladenov avatar
    2891 posts

    Posted 19 Nov 2014 Link to this post

    Hi Aakansha,

    Could you please check in your code whether the following line returns null:
    this.diagram.ContainerGenerator.ContainerFromItem(this.maintViewModel.Source.Items.OfType<object>().ElementAt(0))
    It might be too early after paste and the container might not have been generated yet.

    Also could you please try LayoutAsync instead of Layout and let us know if this layouts the shapes correctly ?

    Regards,
    Petar Mladenov
    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. UI for WPF is Visual Studio 2017 Ready
Back to Top