Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multiline for WPF TextBox

I am developing an app for sending some feedback.

Basically I'm trying to make a TextBox for comments, but I'm used to the WinForms MultiLine=true. I've set MinLines to 3, which is getting there, but preferably I'd like it if the user is able to type wherever in this block - like press enter and do dot points sort of thing. For example:

- Item 1        blah - Item 2                blahlb lahbvl   d 

But at the moment the text all stays on one line.

- Item 1         blah - Item 2                      blahb blahb blah 

These comments will then help fill the body of an email which is sent. It may be pointless if I can't easily keep the same formatting when putting this string into the email body string (so that it looks like it does when sent as it does when typed).

Can I achieve what I'm after or do I have to leave it as all text on one line?

like image 567
baron Avatar asked Apr 16 '10 02:04

baron


People also ask

How to make TextBox multiline in WPF?

Making a Textbox multiline in WPF is pretty simple. You just need to set the AcceptsReturn property to true from the Textbox element and the TextWrapping property to Wrap. This will give you the wanted effect.

How do I wrap text in TextBlock WPF?

In WPF, the Label control does not support text wrapping. If you need a label that wraps contents across multiple lines, you can use a TextBlock control. Place a TextBlock control inside a Label and apply wrapping on TextBlock.

Which property allows multiple line input in TextBox?

A multiline text box allows you to display more than one line of text in the control. If the WordWrap property is set to true , text entered into the multiline text box is wrapped to the next line in the control.

What is the difference between TextBox and TextBlock in WPF?

Text inside a TextBlock can not be made selectable by the user. TextBoxes are used for displaying text more focused for content input or when content is needed to be made selectable by the user. The TextBox can only be set to one colour, one font size, one font type etc.


1 Answers

Enable TextWrapping="Wrap" and AcceptsReturn="True" on your TextBox.

You might also wish to enable AcceptsTab and SpellCheck.IsEnabled too.

like image 78
itowlson Avatar answered Sep 20 '22 18:09

itowlson