title: Highlight part of text in a textblock that is in a Listbox DataTemplate (WPF)
body: <p>Hi I want to highlight part of a text that is in a texblock and that textblock is in a datatemplate of a listbox. I'm trying to do this as the user is searching through a list from entering text in a textBOX. (It is something similar to when searching in Windows File explorer)
  The textblock is bound to a property of a custom class.</p>
  
  <p>Here is the XAML of the listbox DataTemplate</p>
  
  <pre><code>&lt;ListBox Grid.Row="1" HorizontalContentAlignment="Stretch" Name="
      &lt;ListBox.ItemTemplate&gt;
          &lt;DataTemplate&gt;
              &lt;Grid Name="me" Height="25" Margin="0,2"&gt;
                  &lt;DockPanel&gt;
                      &lt;TextBlock DockPanel.Dock="Left" FontSize="15" TextAlignment="Center" Text="{Binding ProductID}"&gt;&lt;/TextBlock&gt;
                      &lt;Image HorizontalAlignment="Right" MouseUp="listboxStockPickItems_AddClick" DockPanel.Dock="Right" VerticalAlignment="Stretch" Margin="0,0,5,0" Cursor="Hand" Width="20" Height="20" Source="/Images/addItem.png"&gt;&lt;/Image&gt;
                  &lt;/DockPanel&gt;
              &lt;/Grid&gt;
          &lt;/DataTemplate&gt;
      &lt;/ListBox.ItemTemplate&gt;
  &lt;/ListBox&gt;
  </code></pre>
  
  <p>Here is the custom class</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Runtime.Serialization;
  using System.Text;
  using System.Threading.Tasks;
  
  namespace UCServer
  {
  [Serializable]
  public class Articulo
  {
      public int ID { get; set; }
  
      public string ProductID { get; set; }
  
      public string Name { get; set; }
  
      public int Amount { get; set; }
  
      public double Price { get; set; }
  }
  }
  </code></pre>
  
  <p>Any help will be greatly appreciated!</p>