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

Add strings to RadDiagramShapes without transparency

2 Answers 60 Views
Diagram, DiagramRibbonBar, DiagramToolBox
This is a migrated thread and some comments may be shown as answers.
Fabian
Top achievements
Rank 1
Fabian asked on 08 Oct 2020, 01:03 PM

Hello!

I am experiencing some problems using custom RadDiagramShapes. What i am trying to achieve is a custom shape, that provides multiple TextAreas that show different information. Therefore, i implemented an ElementShape and a RadDiagram shape. The ElementShape uses the AddString Method of the graphicspath to add my TextAreas, and the RadDiagramShape uses this ElementShape and sets the InternalElementColor.

 

The problem with this is, that i can not click to select or drag my custom RadDiagramShape anywhere because the TextAreas cover the majority of the Shape, and when selecting any transparent spaces (generated from the AddString method) the underlying element will be selected. 

 

Can you give me an idea of how to add such TextAreas to my control without generating lots of transparent / unclickable spaces?

 

Thank you

2 Answers, 1 is accepted

Sort by
0
Accepted
Dess | Tech Support Engineer, Principal
Telerik team
answered on 12 Oct 2020, 08:55 AM

Hello, Fabian,   

As every RadElement derivative, RadDiagramShape also allows inserting other elements in it. Thus, you can add a LightVisualElement to display the text you need. I have prepared a sample code snippet for your reference: 

            RadDiagramShape shape = new RadDiagramShape();
            shape.Shape = new RoundRectShape(1);
            shape.BackColor = Color.Red;
            this.radDiagram1.AddShape(shape);

            StackLayoutElement container = new StackLayoutElement();
            container.Orientation = Orientation.Vertical;
            container.StretchHorizontally = true;
            container.StretchVertically = true;

            LightVisualElement yellowPart = new LightVisualElement();
            yellowPart.ForeColor = Color.Yellow;
            yellowPart.Text = "First";
            yellowPart.StretchVertically = false;
            container.Children.Add(yellowPart);

            LightVisualElement limePart = new LightVisualElement();
            limePart.ForeColor = Color.Lime;
            limePart.Text = "Second";
            limePart.StretchVertically = false;
            container.Children.Add(limePart);

            shape.Children.Add(container);

I hope this information helps. If you need any further assistance please don't hesitate to contact me. 

Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik

Five days of Blazor, Angular, React, and Xamarin experts live-coding on twitch.tv/CodeItLive, special prizes, and more, for FREE?! Register now for DevReach 2.0(20).

0
Fabian
Top achievements
Rank 1
answered on 12 Oct 2020, 02:30 PM

Works like a charm

 

Thank you very much

Tags
Diagram, DiagramRibbonBar, DiagramToolBox
Asked by
Fabian
Top achievements
Rank 1
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Fabian
Top achievements
Rank 1
Share this question
or