XAML Tip: Adding a Line Break to a TextBlock

I'm just starting to mess with XAML as I'm looking to see what I can do with it. As I come across some pretty basic tasks that I'm struggling with, I'll post about it in case any other newbies run into the same issue. One of my first tasks was to create some text on a canvas. However, I couldn't figure out how to do a line break. After searching Live and Google in an attempt to find something, I finally did (on page 3 of each engine). There is an object called <LineBreak/> that will perform a line break in your text. For example:

<TextBlock Margin="5,5,5,5">This is line 1.<LineBreak/>This is line 2.</TextBlock>

Published Monday, April 07, 2008 4:50 PM by Jason N. Gaylord

Comments

# re: XAML Tip: Adding a Line Break to a TextBlock

Tuesday, April 08, 2008 4:04 PM by Bob

Thanks for the tip!

# re: XAML Tip: Adding a Line Break to a TextBlock

Wednesday, April 16, 2008 11:31 PM by Maslarm

<LineBreak/> doesn't work in used Response.Write(xmlDoc.OuterXml);

# re: XAML Tip: Adding a Line Break to a TextBlock

Thursday, July 17, 2008 3:23 PM by Ed

Does this work if you want to bound the text to a resource (i.e. localization)?

Leave a Comment

(required) 
(required) 
(optional)
(required)