更改TextBox wpf C#中存在的部分文本的字体颜色 [英] Change font color of part of text present in TextBox wpf C#

查看:2049
本文介绍了更改TextBox wpf C#中存在的部分文本的字体颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在WPF应用程序中有一个TextBox.

I have a TextBox in WPF application.

例如,文本为"Hello".现在,如果我输入"World",则前景色为黑色.在同一文本框中,我需要更改前景色.

Example the Text is "Hello" with foreground color as Black, now if I type "World" in the same textbox I need to change the foreground color.

那么如何更改TextBox中部分文本的前景色? (要求不是使用TextBox而是RichTextBox)

So how to change foreground color of part of the text in TextBox? (The requirement is to use TextBox not RichTextBox)

预先感谢.

推荐答案

在WPF中,要使文本具有不同的颜色,您需要使用RichTextBox.  文本框有一种颜色.
In WPF to have text with different colours you need to use a RichTextBox.  There is one colour available for a TextBox.


这篇关于更改TextBox wpf C#中存在的部分文本的字体颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆