views:

123

answers:

2

How can I different design the text within the TextBox-Element in XAML

Example: I need the first word normal fontweight and the second word bold...

+4  A: 

You need to use the WPF RichTextBox control for that.

Example:

<RichTextBox x:Name="txtRichBox">
                        <FlowDocument>
                            <Paragraph>
                                I am bold inside
                                <Bold>not outside</Bold>
                            </Paragraph>
                        </FlowDocument>
</RichTextBox>

This should create a textbox with content like

I am bold inside not outside.

Read more with samples here.

Pradeep
works fine, thx
Mario Priebe
I didn't know about the relationship between flow docs and RTBs in WPF. Awesome.
Will
+1  A: 

WPF includes a crapton of framework classes for documents. If you're not looking to edit styled text but to display it, check out Flow documents. If you're looking to edit styled text, then Sizzler's answer is correct.

Will