We pay for user submitted tutorials and articles that we publish. Anyone can send in a contributionLearn More
Last week I was in the need to use a WPF TextBox that had multi line capabilities. I started Typing Multi and hit CTRL + Space to get the intelisense and I was shocked! No MultiLine TextBox, I did get the following:
But no MultiLine TextBox. I refused to believe so I headed on to the Visual Studio Toolbox and after a few minutes of search I finally gave up and opened up Google to search for a MultiLine TextBox. As it turns out it does exists and all you have to do is use a regular WPF TextBox and set the AcceptsReturn Property to True.
All of this is nice but it is not why I am writing this lets assume you need to write the following data into the TextBox:
I bet what most of you would write (and me too up until last week) will be this:
This will work but if you are writing an application that will need to be localized or operate in different environments you will suffer dearly for your decision to use “\n” as you new line “maker”.
Always use Environment.NewLine when in need to signal a new line.
Tags :AcceptsReturnAppendTextMultiLineMultiLine TextBoxNewLineTextBoxWPF
Copyright © 2012 Dev102.com
Breeze : Designed by Amit Raz and Nitzan Kupererd