Question

I am using Windows Store Apps and trying to make a text box with multiline and scrollbars.

I'm assuming this should be very easy to implement as in WPF.

How can I achieve this? Thanks a lot!!

Was it helpful?

Solution

I'll answer here since I can't add images in the comments. As I suggested, take a look at the templates. In the grid template (in both the grid and split template) there is the RichTextColumns.cs that should provide some inspiration.

enter image description here

enter image description here

You can see a simple use of the RichEditBox control, or/and a combination with a more 'advanced' scenario, the multicolumn. The RichEditBox is found in the XAML toolkit for all Windows STore Apps, the column is just an example implementation found in the two templates.

If you just want multiline and scrolling you just use the RichEditBox control. Set textwrapping to wrap, and AcceptsReturn property to true. Wrap it in a scroll if you want to, but keep in mind what I said about horizontal and vertical scrolling.

If you look at the documentation for the control you will even find an example. If you want something else, provide more information above, but make sure you research first.

From MSDN documentation: (and I recommend you read this and the guidelines)

Choosing the right multi-line text input control When users need to enter or edit long strings, use a multi-line text control. There are two types of multi-line text input control.

For plain text, use a TextBox control. Set the AcceptsReturn property to true and set the TextWrapping property to TextWrapping.Wrap.

For formatted text, hyperlinks, inline images, and other rich content, use the RichEditBox control. Set the AcceptsReturn property to true and set the TextWrapping property to TextWrapping.Wrap. If the primary purpose of the multi-line text box is for creating documents (such as blog entries or the contents of an email message), and those documents require rich text, use a RichEditBox control. If you want users to be able to format their text, use a RichEditBox control. When capturing text that will only be consumed, and not redisplayed at a later time to users, use a TextBox control. For example, suppose you have a survey; the user completes the survey and the data is sent to some server, but the user doesn't ever see it again. It is generally unnecessary to allow users to style this text.

For all other scenarios, use a TextBox control whenever possible.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top