I have a WPF application, that has a number TextBox elements. The user fills those out, and the application then prints them. The problem with TextBoxes is that if you keep typing in one, once you fill it out to the end, the text starts scrolling horizontally to make room for more letters, and you no longer see the first couple letters that were typed in.
It was decided that the solution is to prevent the user from entering more text that will fit inside the TextBox. What's the best way of going about it?
I looked at TextBox properties, and didn't see anything that would do what I want directly. The first idea, is to set wrapping to Wrap. Then subscribe to PreviewTextInput event, and if the number of lines is going to exceed 1, handle the event without adding newly typed in text. Obviously you'll still be able to get around it by pasting text, but the bigger issue is that it will only work for single line TextBoxes, and I need it to work with multiline TextBoxes as well.
Is there a better approach that I'm missing? Would calculating text width, and then making sure it's less than TextBox width/height (how?) be a better option? Or perhaps another solution?
Grid
and it will auto size to fit the area, but won't grow. Only other thing I can think of is manually setting the MaxWidth. – TyCobb