I’m using a TextBox control and want the characters to turn red after a certain number of characters to show users they have typed too much. I don’t want to truncate as the user might have typed that “really important thought” and if I truncated they would lose it. I have validation on my underlying business model which tells me when the input is invalid and I style my TextBox to show invalidity.
I want to Style the text as well. Can I do this using a TextBox, or do I need to go to a RichTextBox? My underlying value is just a straight string.
I assume you’re using the stock WPF validation mechanism –
ValidationRules. If so, you should define aTriggeronValidation.HasError == true, and setTextBoxproperties as needed. For example, the following will highlight text with red if it’s invalid.