Hello i have noticed few weird/wrong behaviors of containers.
Based on your MVVM demo application:
Select node : A4 in Audi group
Select node Volkswagen Group.
Move Volkswagen group by 1px
In such case you removed A4 node from its container, which was dropped correctly.
Hello Bartosz,
Thank you for your feedback.
Indeed, exposing some API to be able to customize this behavior seems like a reasonable request. That's why I'm converting this bug report to a feature request and we will think of possible ways to allow for such customization in the future.
For the time being, I can suggest handling the SelectionChanged event (for example) in a similar manner:
private void diagram_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (e.AddedItems != null && e.AddedItems.Count > 0)
{
var containerItem = e.AddedItems[0] as ContainerNodeViewModelBase<object>;
var container = this.diagram.ContainerGenerator.ContainerFromItem(containerItem) as RadDiagramContainerShape;
if (container != null)
{
foreach (var shape in this.diagram.Shapes)
{
if (container.ContentBounds.Contains(shape.Bounds))
{
var shapeItem = this.diagram.ContainerGenerator.ItemFromContainer(shape) as NodeViewModelBase;
if (shape.ParentContainer == null && shapeItem != containerItem && !containerItem.InternalItems.Contains(shapeItem))
{
containerItem.AddItem(shapeItem);
}
}
}
}
}
}
This logic will iterate all the shapes and determine if any of them are placed on top of the selected container - if that is the case, they will be added to it and once you start the drag operation, these shapes will be dragged as well.
You can extract this logic in a separate method and call it if this check needs to be performed at a different moment - when programmatically moving a shape, for example.
Please let me know if such an approach would work for you for the time being.
Regards,
Dilyan Traykov
Progress Telerik
Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.
Hello Stenly,
Thank you for your information, could you share how i could override such behavior of RadDiagram? Is this possible :)?
I tried to override method from RadDiagramShape:OnItemsCollectionChanged but this was too late for such "block operation".
Regarding adorner it seems that if SelectedItems >= 2 then when onDrop is performed you're checking the place where mouse was released, it's good behavior when you're dropping SelectedItems on some node. In case when mouse was released on blank surface of RadDiagram you could check each of selectedItems where they were dropped. If there is some Shape then you could add to it. However the best thing would be to expose some virtual method/property mode(e.g like "Telerik.Windows.Diagrams.Core.SelectionMode.Extended" to let user decide what he would like to do.
Best Regards,
Bartosz
Hello Bartosz,
This is the default behavior of the RadDiagram element because all of its items are rendered as a flat collection on a single surface and the shapes are only logical children of the containers. This could be observed by using a spying utility, such as Snoop, which would allow you to inspect the visual tree of the RadDiagram control. Moreover, when the container and, for example, a RadDiagramShape are selected, they are automatically placed in a selection adorner, which allows the user to drag them around the RadDiagram control's surface.
With that said, I hope the provided information is of help to you.
Regards,
Stenly
Progress Telerik
Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.