C# Change color of one character in a text box

.net, c#, wpf

Solution

You can not do this with a textbox, but you can use a richtextbox: WPF RichTextBox Tutorial

var textRange = MyRichTextBox.Selection;
var start = MyRichTextBox.Document.ContentStart;
var startPos = start.GetPositionAtOffset(0);
var endPos = start.GetPositionAtOffset(1);
textRange.Select(startPos, endPos);
textRange.ApplyPropertyValue(TextElement.ForegroundProperty, new SolidColorBrush(Colors.Blue));

Problem

C# - WPF : how can I change the color of just one character in a text box ? example : Word Hello, Color of H becomes Red

Original source