#245 – Easily Inline Text Formatting Codes with TextBlock Control

You can specify a TextBlock control’s content by defining a series of Run elements.

You can also just specify the text by setting the child element of the TextBlock:

		<TextBlock>
			Henry V was here.
		</TextBlock>

Finally, you can include some formatting tags directly in the body of the text:

		<TextBlock Margin="10" Height="100" FontSize="14" Width="290" TextWrapping="Wrap">
			We <Bold>few</Bold>, we happy <Bold>few</Bold>, we band of <Underline>brothers</Underline>;
For he to-day that sheds his <Italic>blood</Italic> with me
Shall be my <Underline>brother</Underline>; be he ne'er so <Italic>vile</Italic>,
This day shall <Bold>gentle</Bold> his <Italic>condition</Italic>;"
		</TextBlock>

Advertisement