Is there a way to have \\n
make a line break in a TextBlock
?
Or is there a
How about breaking the line into two tags?
<StackPanel>
<TextBlock Text="Line1" />
<TextBlock Text="Line2" />
</StackPanel>
Correct way to use it may be the following :
<TextBlock>
<Span>text1</Span>
<LineBreak/>
<Span>text2</Span>
</TextBlock>
I was having a similar problem and wanted to bind a String of xaml markup to a TextBlock. Essentialy storing the declarative markup inside a TextBlock in a string for later use.
This is how I did: I subclassed the TextBlock to make the InlineCollection bindable and wrote a Converter between the string and an InlineCollection(or actually a generic list of Inlines.)
The easiest way is
<TextBlock> blabla <LineBreak /> coucou <LineBreak /> coucou 2 </TextBlock>
So you just write XAML code, and the <LineBreak />
has exactly the same meaning the
in HTML or the "\n" in C#.
<LineBreak/>
http://www.longhorncorner.com/UploadFile/mahesh/XamlLineBreak06092005152257PM/XamlLineBreak.aspx
This also works fine:
<TextBlock>
<Run Text="My nice text"/>
<LineBreak/>
<LineBreak/>
<Run Text="After some linebreaks, I'm back!"/>
</TextBlock>