I am using RadDiagram, where I will have two container shapes (RadDiagramContainerShape) Front and Rear. User will choose a device and drop it into the front/rear block, so a diagram shape will be created and added into front/rear block. But once I added, the parent container shape resized even I added a shape with same width of parent.
How to disable the auto resizing of parent container shape.
Regards,
Jawahar
8 Answers, 1 is accepted
The auto resizing is build in the RadDiagramContainers but with Q3 2013 we released a couple of virtual methods(CalculateShapeBounds, CalculateContentBounds and CalculateMinShapeBounds) that you can override and change the default container behavior.
I've attached a sample project with very simple implementation of fixed container - turned off the container resizing and overrode the CalculateContentBounds so that it doesn't auto resize on item drop.
I hope I was able to help you and if you have more questions please feel free to ask.
Regards,
Zarko
Telerik
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Hi
How do we disable auto resize in MVVM scenario? I have a Container class that derives from ContainerNodeViewModelBase<object> and I want to disable auto resize when another element is dropped in this container.
Regards,
Elango
Тhe same approach as the one explained in the Zarko's reply can be used also in an MVVM scenario. Basically, you can create a custom container shape that derives from the RadDiagramContainerShape class and override its CalculateContentBounds() method.
public
class
FixedContainer : RadDiagramContainerShape
{
protected
override
System.Windows.Rect CalculateContentBounds(System.Windows.Rect newShapeBounds)
{
return
this
.ContentBounds;
}
}
Regards,
Martin
Telerik
Hello Martin,
Thanks for the response. Sorry as I couldn't check this immediately. I created a custom diagram class as you mentioned. When I try to drag and drop a container element (from toolbox) to the diagram I am getting the following error
'FixedContainer' TargetType does not match type of element 'RadDiagramContainerShape'.
This occurs in the AddNode method in GraphSource class.
Note: GraphSource is my custom class derived from SerializableGraphSourceBase<NodeViewModelBase, Link>
The described exception is thrown because the ContainerShapeStyle of the diagram targets the FixedContainer shape. This still is applied in code by the diagram to all container shapes when they are added. On the other hand the shape dropped from the toolbox is of type RadDiagramContainerShape. In other words a Style that targets FixedContainer is applied on an element of type RadDiagramContainerShape which is not allowed by the WPF framework and an exception is thrown.
To resolve this error you can populate the toolbox with custom items and add the FixedContainer as a shape of the container toolbox item. This way when you drop it, the correct container will be added in the diagram and the exception won't be thrown.
I hope this helps.
Regards,
Martin
Telerik
@Martin Hi, Martin. Sorry for jumping to this thread. I want to rearrange its children when a RadDiagramContainerShape resized. But I found that, a RadDiagramContainerShape cannot be resized by drag the resize thumb if a child is positioned at the corner of this container shape.
For example, In the attached screenshot, you cannot resize the container by dragging the southeast corner.
How to override this behaviour? Seems override CalculateShapeBounds does not help.
I will try to reproduce this and I will get back to you later today with more information this.
Regards,
Martin Ivanov
Progress Telerik
I've tested this on my side but I wasn't able to reproduce the issue. Can you please take a look at the attached project and let me know if I am missing something?
Regards,
Martin Ivanov
Progress Telerik