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

2 posts, 0 answers
  1. John
    John avatar
    1 posts
    Member since:
    Feb 2016

    Posted 01 Feb Link to this post

    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)

  2. Yana
    Admin
    Yana avatar
    4554 posts

    Posted 03 Feb Link to this post

    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
  3. UI for WPF is Visual Studio 2017 Ready
Back to Top