If I want to display an underlined value in a TextBlock, I have to use a Run element. (If there’s a better/easier way, I’d love to hear about it.)
<TextBlock> <Run TextDecorations='Underline' Text='MyText' /> </TextBlock>
Ideally, to implement this within a DataTemplate, it would look something like this:
<DataTemplate x:Key='underlineTemplate'> <TextBlock> <Run TextDecorations='Underline' Text='{Binding Value}' /> </TextBlock> </DataTemplate>
This won’t work, however, because the Run’s Text property isn’t a DependencyProperty, so you can’t databind to it. Does anyone know how I can accomplish this?
TextDecoration is an attached property so it can be applied to the TextBlock also. You create some pretty cool effects by templating the TextDecorations property.
See this MSDN article.