barriovolvo
barriovolvo

Reputation:

Best way to decorate databound text in a wpf TextBlock

Let's say I have some multiline text that I'd like to format, and let's also say that it's databound. So, in XAML:

<TextBlock TextWrap="Wrap">
    <TextBlock.Inlines>
        <Run TextWeight="Bold" Text="{Binding Path=FirstName}" />
        <Run TextStyle="Italic Text="{Binding Path=LastName}" />
    </TextBlock.Inlines>
</TextBlock>

Now, this doesn't work because Run's Text isn't a dependency property. So, I'm wondering, what is the best way to style inline databound text like this?

Thanks in advance.

Upvotes: 2

Views: 1791

Answers (1)

Andrew Barrett
Andrew Barrett

Reputation: 19911

There is a workaround posted here. It basically involves subclassing Run to be bindable. Works though.

Upvotes: 1

Related Questions