Tener texto codificado con un enlace en un TextBlock


En WPF, ¿hay alguna manera de tener la propiedad Text de un TextBlock para contener tanto texto codificado como un enlace específico?

Lo que tengo en mente es algo en la línea de lo siguiente ( por supuesto, lo siguiente no compila):

<TextBlock Text="Number of Fans: {Binding Artist.Fans.Count}"></TextBlock>
Author: Erno de Weerd, 2009-04-25

4 answers

Si está en. Net 3.5 SP1

<TextBlock Text="{Binding Path=Artist.Fans.Count, 
                 StringFormat='Number of Fans: {0}'}" />
 75
Author: Scott Weinstein,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2014-09-11 14:13:54

Al utilizar el enfoque anterior:

<TextBlock Text="{Binding Path="Artist.Fans.Count", 
                  StringFormat='Number of Fans: {0}'}" />

Me pareció algo restrictivo ya que no pude encontrar una manera de poner la cara en negrita dentro del StringFormat ni pude usar un apóstrofo en el StringFormat.

En su lugar, me fui con este enfoque, que funcionó mejor para mí:

<TextBlock TextWrapping="Wrap">
    <Run>The value</Run>
    <Run Text="{Binding Path=MyProperty1, Mode=OneWay}" FontWeight="Bold" />
    <Run>was invalid. Please enter it with the format... </Run>
    <LineBreak/><LineBreak/>
    <Run>Here is another value in the program</Run>
    <Run Text="{Binding Path=MyProperty2, Mode=OneWay}" FontWeight="Bold" />
</TextBlock>                    
 30
Author: doogie,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2012-12-12 22:10:08

Uso Binding.StringFormat:

<TextBlock Text="{Binding Artist.Fans.Count, StringFormat='Number of Fans: {0}'}"/>
 4
Author: Danko Durbić,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2009-04-25 16:16:35

Aquí el valor de enlace(nubes.all) se añade con"%". Puede agregar cualquier valor que desee después de " \{0\}".

 <TextBlock Text="{Binding Path=clouds.all, StringFormat=\{0\}%}"/>
 2
Author: reza.cse08,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2015-10-30 08:25:03