This is a migrated thread and some comments may be shown as answers.

Disable auto resize in RadDiagramContainerShape

8 Answers 317 Views
Diagram
This is a migrated thread and some comments may be shown as answers.
Jawahar
Top achievements
Rank 1
Jawahar asked on 19 Nov 2013, 09:01 AM
HI there,

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

Sort by
0
Zarko
Telerik team
answered on 22 Nov 2013, 09:14 AM
Hello Jawahar,
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
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
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 >>
0
Elango
Top achievements
Rank 1
answered on 20 Nov 2015, 11:08 AM

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

0
Martin Ivanov
Telerik team
answered on 24 Nov 2015, 09:07 AM
Hello 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;
    }
}
However, in order to use this container in an MVVM scenario you will also need to create a custom diagram and override its GetShapeContainerForItemOverride() method. You can find an example that demonstrates such scenario in the Create Custom Shape help article.

Regards,
Martin
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Elango
Top achievements
Rank 1
answered on 08 Dec 2015, 08:50 AM

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>

0
Martin Ivanov
Telerik team
answered on 11 Dec 2015, 09:29 AM
Hi Elango,

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
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
rick
Top achievements
Rank 1
answered on 13 Aug 2018, 09:20 AM

@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.

 

0
Martin Ivanov
Telerik team
answered on 16 Aug 2018, 08:52 AM
Hello Rick,

I will try to reproduce this and I will get back to you later today with more information this.

Regards,
Martin Ivanov
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Martin Ivanov
Telerik team
answered on 17 Aug 2018, 06:54 AM
Hi Rick,

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
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
Diagram
Asked by
Jawahar
Top achievements
Rank 1
Answers by
Zarko
Telerik team
Elango
Top achievements
Rank 1
Martin Ivanov
Telerik team
rick
Top achievements
Rank 1
Share this question
or