How to change Text color of RadDiagramConnection dynamically based on its value?

1 Answer 137 Views
Diagram
Aeroth
Top achievements
Rank 1
Aeroth asked on 11 Jul 2021, 04:12 AM

I'm creating the shapes, connections programmatically based on my custom configuration file.

I'd like to change the Text color of RadDiagramConnection based on its value, like: OK-> Black; NG-> Red

See below screenshot,

Could you show me how to do it? Thanks!

1 Answer, 1 is accepted

Sort by
1
Stenly
Telerik team
answered on 13 Jul 2021, 12:51 PM

Hello Aeroth,

One way of dynamically changing the color of the RadDiagramConnection content is by checking if the content value matches a certain requirement and that is done by changing the Foreground property. I am attaching a code snippet for your convenience:

 

this.diagramConnection.Foreground = Brushes.Red;

 

As well as the snippet I am attaching an example project for a possible solution to your question.

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

Aeroth
Top achievements
Rank 1
commented on 13 Jul 2021, 12:59 PM

Hi Stenly, thanks for the solution. Is there an event like ConnectionTextEditCompleted? So that I could change the color instantly.
Stenly
Telerik team
commented on 14 Jul 2021, 12:13 PM

Hello Aeroth,

You could look at EndEdit event which fires when you finish editing an item.

The following code snippet shows where to put the event into the RadDiagramConnection control:

<telerik:RadDiagramConnection  EndEdit="radDiagramConnectionLine_EndEdit"

I am attaching an example project to show the logic behind the event.

Aeroth
Top achievements
Rank 1
commented on 14 Jul 2021, 02:27 PM

Hi Stenly, thanks for your solution.
Tags
Diagram
Asked by
Aeroth
Top achievements
Rank 1
Answers by
Stenly
Telerik team
Share this question
or