Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Silverlight TextBlock Text Attribute vs Content

When would I use the Text attribute of the <TextBlock> and when should I put my text in the content of the <TextBlock>?

<TextBlock Text="Example Text" />

            vs.    

<TextBlock>Example Text</TextBlock>
like image 741
amurra Avatar asked Apr 22 '26 20:04

amurra


1 Answers

The former can be bound, whilst the latter is particularly useful when combining Runs:

<TextBlock Text="{Binding SomeProperty}"/>
<TextBlock>
    <Run>You have </Run>
    <Run Text="{Binding Count}"/>
    <Run>items.</Run>
</TextBlock>
like image 89
Kent Boogaart Avatar answered May 04 '26 07:05

Kent Boogaart



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!