Best way to decorate databound text in a wpf TextBlock
-
05-07-2019 - |
Question
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.
Solution
There is a workaround posted here. It basically involves subclassing Run to be bindable. Works though.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow