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

How can I add different color lines of text to an item .... ?

1 Answer 23 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
John
Top achievements
Rank 1
John asked on 01 Feb 2016, 03:18 PM

Hi all,

I can't find even one simple example that shows how to do that.

I need to put an item on the panel (I don't care if it's Listbox or TextBlock or RichTextBox) that will let me add lines of text while running, from the ViewModel code, each line with a color that I choose.

For example:

"This is red line of text" (this text will be red)

"This is blue line of text" (this text will be blue)

 

What it the simplest way to do that ?

Thanks very much!

(It's in WPF - MVVM)

1 Answer, 1 is accepted

Sort by
0
Yana
Telerik team
answered on 03 Feb 2016, 02:58 PM
Hi John,

Аs far as I understand the requirement,  I would suggest you check our RadListBox control - you could bind its ItemsSource to a collection in the ViewModel and also you could customize its ItemTemplate, so that the Text is colored differently according to some property of the used items. You could also take a look at the ListBox First Look example at WPF Demos.

I hope this will help get started.

Regards,
Yana
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
Tags
General Discussions
Asked by
John
Top achievements
Rank 1
Answers by
Yana
Telerik team
Share this question
or