9
votes

I want to create a UI element that behaves approximately like the native WP SMS App's input text box.

Basically it should

  • start as a single line text box
  • when my text reaches the end of the first line, it should expand one line to encompass it
  • this needs to go to a Max Height of 5 line (where a line = the text box's Height value)
  • once my text requires more than 5 lines, the text box should stop expanding and a vertical scroll bar should appear

Any suggestions on how I can do this? I'd rather not use events to see how much text I've entered and expand/compress the text box based on that, or create a new UI element from scratch.

If it helps, I've got access to Telerik's RAD Controls for Windows Phone (RadTextBox).

1

1 Answers

21
votes

Have you attempted making use of the FrameworkElement.MaxHeight property? The markup would be similar to:

<TextBox TextWrapping="Wrap" AcceptsReturn="True" MaxHeight="200" />

The given value for max height is simply an example and may not meet your specific needs.

Note: As mentioned in the comments below, be certain to remove any value specified for Height. The declaration will constrain the element to that height at all times.