S
S
skvoshiz2016-04-17 05:18:22
Programming
skvoshiz, 2016-04-17 05:18:22

How to make different line color in WPF TextBox?

Hello, how to make different line color in WPF TextBox?
It is necessary that the text be red on the first line, green on the second ...
It is advisable to answer with an example, because. I'm not experienced yet.
Thanks for the replies =)

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Andryukha, 2016-04-17
@syrov

If you need text coloring, then RichTextBox is probably better.
For the background, there are perverse methods, such as placing an element with a transparent background on the Canvas, on which to actually draw whatever you want. I did this in Silverlight a long time ago. Probably the same in WPF, although it can do more.

A
AxisPod, 2016-04-18
@AxisPod

If it's just an output without editing, then dig towards TextBlock + Run. TextBox does not support coloring out of the box. Here, only RichTextBox is standard, but in your case it may not be very easy. But although there is not much choice.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question