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

Diagram container shape padding/margin ?

7 Answers 243 Views
Diagram
This is a migrated thread and some comments may be shown as answers.
nicolasf
Top achievements
Rank 2
nicolasf asked on 14 Aug 2017, 05:35 PM

Hi,

I try tu re-use TableShape example and specificaly styles and i have a problem when iadd a Row into Table. each element shift on the left (see capture 1) If i force width, the problem is the same.
The row is not stretch to te container and create a resizing of the container. (i have 10px on the left and the right side, see the capture 2). How to remove this padding or margin ?

The last problem is when i add or delete a row, the event OnItemsCollectionChanged in TableShape class is not trigged, maybe i missed a binding ?

Can you help me please.
Thanks a lot,
Nicolas

7 Answers, 1 is accepted

Sort by
0
Martin Ivanov
Telerik team
answered on 17 Aug 2017, 09:07 AM
Hello Nicolas,

I am not sure how you add the row shapes, but my guess the observed behavior in capture1.png is caused by the auto-resizing mechanism of RadDiagramContainerShape. Basically, the container is trying to always provide some margin between its borders and its children shapes. This is why if you position a shape withing this minimum distance (the margin), the container will be automatically resized. 

To avoid this behavior I would suggest you couple of approaches.
  • The first one is to make sure that the shape is added outside of the minimum distance. So for example if the X position of the table shape (the container shape) is at the 20th pixel,  the child's X should be at least on the 30-40th pixel.
  • The other approach is to override  the CalculateContentBounds method in the TableShape class and return the original bounds. This way you'll avoid the auto-resizing mechanism. You can find some information about this in the following forum.
    protected override System.Windows.Rect CalculateContentBounds(System.Windows.Rect newShapeBounds)
    {
        return this.ContentBounds;
    }

About the OnItemsCollectionChanged, I checked this with the TableShape demo, but the method is called properly when you delete or add a row. I tested this using the Delete key and also the '+' and '-' buttons which are displayed when you click on the table shape's header.

Regards,
Martin Ivanov
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
0
nicolasf
Top achievements
Rank 2
answered on 17 Aug 2017, 09:34 PM
Thanks for your answer.

I found why event wasn't trigging. I was 2 problems, first in the style "tableStyle" i used as targetType "RadDiagramContainerShape" instead of "TableShape". The second one is i didn't extend RadDiagram just like SqlDiagram example to override GetShapeContainerForItemOverride and GetShapeContainerForItemOverride.

But i still the same problem with rowShape whose shifting on left event i override CalculateContentBounds.

if you can help me to find a solution please ? i can send you the code to understand the problem

Thanks a lot !

Nicolas
0
Martin Ivanov
Telerik team
answered on 22 Aug 2017, 10:17 AM
Hello Nicolas,

I am not sure why this happens. If you can share runnable code reproducing the described behavior I will check what is going on.

Regards,
Martin Ivanov
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
0
nicolasf
Top achievements
Rank 2
answered on 22 Aug 2017, 08:53 PM

Hello Martin,

Thanks for your answer, you can find example on my github account : https://github.com/Silocan/TelerikDiagramDemo

Thanks for your help,

Nicolas

0
Martin Ivanov
Telerik team
answered on 24 Aug 2017, 03:09 PM
Hello Nicolas,

I wasn't able to reproduce the size expanding behavior when commented the CalculateContentBounds override. However, I hit another issue - the size of the container doesn't update when you add new rows. In order resolve this you will need to manually set the Height property of the container when you add new rows. 

I updated your project to demonstrate a possible approach that you could use. Basically, I update the Height of the TableShape when a new row is added. The same way is updated when a row is removed. I also bound the Width and Height properties of the Row and Table shapes to the Width and Height of their models so that I can use them in the calculations.

I hope this helps.

Regards,
Martin Ivanov
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
0
nicolasf
Top achievements
Rank 2
answered on 28 Aug 2017, 08:33 PM
thanks very much for your help,

i still have a margin on the right of row. i working to resolve this. i'll post the final code once this problem solved
0
nicolasf
Top achievements
Rank 2
answered on 28 Aug 2017, 08:45 PM

i changed RowShape width to 250 (same width than TableShape)

thanks !

Tags
Diagram
Asked by
nicolasf
Top achievements
Rank 2
Answers by
Martin Ivanov
Telerik team
nicolasf
Top achievements
Rank 2
Share this question
or