Here is a (very) rough example keeping stick with TextBox and TextBlock: just for fun, but worthwhile...

Here is the XAML...
<Grid>
<TextBlock
x:Name="Tx1"
HorizontalAlignment="{Binding Path=HorizontalAlignment, ElementName=Tb1}"
VerticalAlignment="{Binding Path=VerticalAlignment, ElementName=Tb1}"
Margin="{Binding Path=Margin, ElementName=Tb1}"
FontSize="{Binding Path=FontSize, ElementName=Tb1}"
/>
<TextBox
x:Name="Tb1"
HorizontalAlignment="Stretch"
VerticalAlignment="Center"
Margin="100,0"
FontSize="24"
Background="Transparent"
Foreground="Transparent"
TextChanged="Tb1_TextChanged"
/>
</Grid>
...and here is some code...
private void Tb1_TextChanged(object sender, TextChangedEventArgs e)
{
var inlines = this.Tx1.Inlines;
inlines.Clear();
foreach (char ch in this.Tb1.Text)
{
if (Char.IsDigit(ch))
{
var run = new Run(ch.ToString());
run.Foreground = Brushes.Blue;
inlines.Add(run);
}
else if (Char.IsLetter(ch))
{
var run = new Run(ch.ToString());
run.Foreground = Brushes.Red;
inlines.Add(run);
}
else
{
var run = new Run(ch.ToString());
run.Foreground = Brushes.LimeGreen;
inlines.Add(run);
}
}
}
The trick is using a transparent TextBox over a TextBlock, which can be colored by collecting many different Run elements.