pmf
pmf

Reputation: 7759

WPF: is there a way to do inline formatting?

Is there a way to use inline formatting (like Swing's HTML tagging within labels) with WPF? I could not find any documentation.

Upvotes: 1

Views: 514

Answers (2)

goobering
goobering

Reputation: 1553

The TextBlock (there may be others) can make use of several inline formatting elements.

[example lifted verbatim from: http://wpf.2000things.com/2011/03/14/245-easily-inline-text-formatting-codes-with-textblock-control ]

<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>

Upvotes: 3

Simon Verbeke
Simon Verbeke

Reputation: 3005

Not quite sure if this is what you're looking for, but XAML uses attributes. Just like in HTML you can say <element attribute="foo"></element>

Upvotes: 0

Related Questions