Question

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

Was it helpful?

Solution

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.

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top