Is it possible to always show a rectangle around grouped shapes? Currently, you can style using GroupStyle the bounding rectangle that appears upon selecting the group. I want that rectangle (or any rectangle with the same style) to also be shown when the group is not selected.
Thanks!
9 Answers, 1 is accepted
Can you instead consider using the RadDiagramContainerShape? The RadDiagramContainerShape allows you to place multiple shapes into one container shape. The RadDiagramContainerShapes are, much like groups, a way to logically combine other shapes but add to this the capability to have a visual wrapper including a header. You can drag shapes in and out of a ContainerShape in runtime and take advantage of its built-in auto-sizing logic that can extend the size of a container to wrap a shape.
Furthermore, you can edit the default ControlTemplate of the RadDiagramContainerShape to create a rectangle-like look and feel. I attached a sample solution demonstrating this approach. Please let me know if it helps.
Regards,
Tina Stancheva
the Telerik team
Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.
Sorry to piggyback on this thread. But I have some questions on making this functionality work (or something like it).
I already use containers to create "rooms" where I'm allowing users to place items. I then need a visual "grouping" so that users can to group these items across containers (one group might contain 0-M items from 0-M rooms) and I need users to be able to see these groups visually while looking at the diagram.
I've tried a variety of other things like use rectangles for the grouping, but as soon as the object gets close to the container, the container grabs it and makes it part of the container.
So is a group rectangle always visible possible, or can you recommend a solution for what I'm trying to achieve?
There is another approach to make the groups rectangle always visible. It is a bit more advanced - involves creating custom GroupsAdorner. The RadDiagram is very extensible in any direction by changing the so called adorners.
Please have take a look at the attached project and let us know if this is working for you.
Hope this helps.
Miro Miroslavov
the Telerik team
Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.
Hi Miro,
I've tried to implement your solution DiagramCustomGroups to my project but i found some issues with it. I got now couple of questions. First one is just informative. Is there any way to set up some ,,Margin,, to group(padding is maybe better word for my case). I'd like to see group around the shapes (default is for example that border of container in group common with border of group).
Second question is more difficult. In previous scenario you've create MyGroupsAdorner class and som custom style for diagram. When i ve tried to use it in my solution there was few case it was not work properly:
- i ve create two groups and after that i ve grouped them to one parent group... it looks fine but after i ve tried to move with group two rectangles from smaller group stay visible and on original position. When i ve ungrouped parent group... shapes came back to original rectangles
Any advice how to manage that. Or it is some more specific tutorial how to work with adorner how to implement visibility for group borders?
Thank you for your time
Greetings
Jakub Rautner
I will try to answer all of your questions in the order they appeared.
About the Padding/Margin of the group - you are right, by default there is no space between the group rectangle and the shapes inside the group. Please have in mind that the GroupAdorner is actually a rectangle, so you can set only the Margin property, but I'm not sure if this is the behavior you are looking for.
As for the multiple groups - before I answer your question I would like to bring your attention to the fact that - if you want to group 2 groups into another parent group, you should select the first group then using Ctrl + MouseClick select the second one and then make parent group from the two others and not make just selection around all the shapes inside the two smaller groups (you can take a look at this video).
So, back to the implementation - in Shape_PropertyChanged() event you should check if the group has ParentGroup and update the position of all groups. For your convenience I implemented this approach in the attached project. Please take a look at it and let us know if it works for you.
Milena
Telerik
Hallo,
i've got few questions about ContainerShape use as Group. I try to implement my own logic to create container and add there selected items from code behind. Is there some separate layout for container content because when i create Group(container) everything is ok... but when lostFocus on this shape, items in container are reoreder to one line and lost previosly positions.
2nd question. I have trouble with copy links. My scenario is like... select few items in diagram. Create group of these items (add them to container) and after double click on container create new diagram in new tab with those items... Everything is fine but i can t manage to copy links to new diagram.
Thank you for answer
About your first question - if you layout the diagram you can take advantage of the layout settings and use LayoutContainerChildren property. For more information you can take a look at our Layout help article. If you mean something else, could you please provide us a small sample demonstrating your scenario (the custom logic for containers you mentioned) with steps to reproduce so that we can investigate this behavior and suggest a suitable approach.
As for the links - I suppose that you hit this issue: Diagram connections' Source and Target bindings don't work inside tab control. If it is so, you can try the proposed solution in the feedback item and use the new NameScopeProvider attached property of the diagram. Please take a look at it and lets us know if it works for you.
I hope this helps.
Regards,
Milena
Telerik
Hallo,
i tried to implement contianer group logic. but when i try create some subgroup in big group of nodes i get error like : "Additional information: An item with the same key has already been added. " i attached sample project. Could you give me some advice how to fix that?
Thank you for your time
Greetings
Jakub
Sample project: https://db.tt/1DKTGatQ
Thank you for the project provided. I was able to reproduce the described behavior.
The reason for the ArgumentException is adding the same diagram item twice in the GraphSource. However, in order to avoid that, when you create a subgroup you should remove the shapes from the parent container (group) and add them only in the new one, then add the nested container (subgroup) to the first one.
You can find a sample implementation of this approach in the attached project. In brief, I get the container of the business object (node) and then the containershape where this node is placed using ParentContainer property. Then I change the ItemSource of the ContainerShape and instead of the separated items, which are selected, I add a new container with the same items inside.
I hope this sample will get you started. Please take a look at the project and see if it works for you.
Regards,
Milena
Telerik