Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>One more approach to try. Use <a href="http://msdn.microsoft.com/en-us/library/system.windows.controls.textblock.inlines.aspx" rel="nofollow noreferrer">TextBlock.Inlines</a>. Then bind your model to the TextBlock, and either in custom <a href="http://msdn.microsoft.com/en-us/library/system.windows.data.ivalueconverter.aspx" rel="nofollow noreferrer">value converter</a> or via custom attached property parse your model to populate TextBlock's inlines. </p> <p>Here is an example of Attached property that takes Text string and makes every second word bold:</p> <pre><code>public class RunExtender : DependencyObject { public static string GetText(DependencyObject obj) { return (string)obj.GetValue(TextProperty); } public static void SetText(DependencyObject obj, string value) { obj.SetValue(TextProperty, value); } public static readonly DependencyProperty TextProperty = DependencyProperty.RegisterAttached("Text", typeof(string), typeof(RunExtender), new PropertyMetadata(string.Empty, OnBindingTextChanged)); private static void OnBindingTextChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { var bindingText = e.NewValue as string; var text = d as TextBlock; if (text != null) { text.Inlines.Clear(); var words = bindingText.Split(' '); for (int i = 0; i &lt; words.Length; i++) { var word = words[i]; var inline = new Run() {Text = word + ' '}; if (i%2 == 0) { inline.FontWeight = FontWeights.Bold; } text.Inlines.Add(inline); } } } } </code></pre> <p>This is not a production quality code, and it's taken from Silverlight demo, but you get the idea.</p> <p>Hope this helps.</p> <p>Cheers, Anvaka.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload