I'm writing a Console for users, so that they can write code in it similar to Visual Studio. I was wondering how to change the color of a set of text in a WPF TextBox as soon as the program detects the input of a certain character, such as the /* */ comment tags.
When a user enters a /* tag, the text after the tag should be colored in green and when the users closes the tags, the texts should turn back to white. I tried doing this with the TextChanged method but I don't know how to proceed.
('console' is the TextBox in my Window)
private void console_TextChanged(object sender, TextChangedEventArgs e)
{
if (e.Changes.Equals("/*"))
{
console.Foreground = Brushes.Green;
}
}