title: Change Color of each word that starts with specific letter
body: <p>I'm working in my getter just as a place to test this, but essentially what I'm trying to accomplish is while the users is typing for every instance of 'D' as the first letter of a word change the color of that text to red. The color change is accomplished by bounding the Foreground of a RichTextBox to my Customers.TColor property.<br>
  My real logic issues are happening in my TColor property as the program worked when getter was just single line(now commented out) looking for just the first character of Character.Name:<br>
   <code>return name.Length &gt; 0 &amp;&amp; name[0] == 'D' ? Brushes.Red : Brushes.Black;</code><br>
  However, I'm trying to extend this functionality to every word. Here is my TColor property logic:</p>
  
  <pre><code> public Brush TColor
      {
          get
          {
              string[] allNames = name.Split(null);
              foreach (string n in allNames)
              {
                  if(n[0] == 'D')
                  {
                      return Brushes.Red;
                  }
                  else
                  {
                      return Brushes.Black;
                  }
              }
              return Brushes.Black;
              //return name.Length &gt; 0 &amp;&amp; name[0] == 'D' ? Brushes.Red : Brushes.Black;
          }
          set
          {
              tColor = defaultColor;
          }
      } 
  </code></pre>
  
  <p>What I'm trying to do is get each word individually, so <code>allNames</code> should be splitting the user input into single words then looks at the first char in each of those if it's a D set the brush to red otherwise set the brush for that word to black. If I backspace out of my default values that is set at construction of a Customer object I get a runtime error.<br>
  <strong>I'm wondering two things</strong><br>
  1. if this is the way I should be trying to change the color of an individual word in a RichTextBody.<br>
  2. How can I effectively look at the first character of each word and change its color.<br>
  Here is what my RichTextBody Currently looks like:  </p>
  
  <pre><code>&lt;StackPanel Orientation="Horizontal" VerticalAlignment="Top" HorizontalAlignment="Center" Margin="10,0,3.4,0" Width="505"&gt;
      &lt;Label Content="Customer name:" /&gt;
      &lt;RichTextBox x:Name="richTextBox" Height="100" Width="366"&gt;
          &lt;FlowDocument&gt;
              &lt;Paragraph Foreground="{Binding Customer.TColor}"&gt;
                  &lt;Run&gt;&lt;/Run&gt;
                  &lt;Run Text="{Binding Customer.Name, UpdateSourceTrigger=PropertyChanged, ValidatesOnDataErrors=True}" /&gt;
              &lt;/Paragraph&gt;
          &lt;/FlowDocument&gt;
      &lt;/RichTextBox&gt;
      &lt;Button Content="Update" Command="{Binding UpdateCommand}"/&gt;
  &lt;/StackPanel&gt;
  </code></pre>
  
  <p>My relevant variables and properties are as follows:</p>
  
  <pre><code>private string name;
  private Brush tColor;
  private Brush defaultColor = Brushes.Black;
  </code></pre>
  
  <p>My constructor is: </p>
  
  <pre><code>public Customer(String customerName)
      {
          Name  = customerName;
          TColor = defaultColor;
      }
  </code></pre>
  
  <p>My Name property is:</p>
  
  <pre><code>public String Name
      {
          get
          {
              return name;
          }
          set
          {
              name = value;
              PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Name"));
              PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("TColor"));
              //OnPropertyChanged("Name");
          }
      }
  </code></pre>
  
  <p>Just in case I left anything out, <a href="https://github.com/m-alt/MVVM" rel="nofollow noreferrer">a repo of the project is here</a></p>