#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

About Sean
Software developer in the Twin Cities area, passionate about software development and sailing.

One Response to #245 – Easily Inline Text Formatting Codes with TextBlock Control

  1. Pingback: #842 – The Differences Between Label and TextBlock | 2,000 Things You Should Know About WPF

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: