title: Get last 3 characters during user typing
body: <p>I need get last three character from richTextBox during when the user writes some text in richTextbox.</p>
  
  <p>I bind property on Text property of richTextBox from Extended WPF toolkit.</p>
  
  <pre><code>public string RtbText
  {
      get { return _rtbText; }
      set
      {
          _rtbText = value;
          NotifyPropertyChanged("RtbText");
      }
  }
  </code></pre>
  
  <p>I use Reactive Extensions for .NET (Rx) and make Observer on property RtbText</p>
  
  <pre><code>    Observable.FromEvent&lt;PropertyChangedEventArgs&gt;(this, "PropertyChanged")
          .Where(e =&gt; e.EventArgs.PropertyName == "RtbText")
          .Select(_ =&gt; this.RtbText)
          .Where(text =&gt; text.Length &gt; 1)
          .Do(AddSmiles)
          .Throttle(TimeSpan.FromSeconds(1))
          .Subscribe(GetLastThreeChars);
  
     private void GetLastThreeChars(string text)
     {
         if (text.Length &gt; 3)
         {
             string lastThreeChars = text.Substring(text.Length - 2, text.Length);
         }
     }
  </code></pre>
  
  <p>But if I start typing in richTextBox I get this exception:</p>
  
  <blockquote>
    <p>Index and length must refer to a location within the string.<br>
    Parameter name: length</p>
    
    <p>at System.String.InternalSubStringWithChecks(Int32 startIndex, Int32 length, Boolean fAlwaysCopy)<br>
       at System.String.Substring(Int32 startIndex, Int32 length)<br>
       at WpfApplication1.MainWindow.GetLastThreeChars(String text) in C:\Users\Jan\Documents\Visual Studio 2010\Projects\C#\Pokec_Messenger\ver.beta\IoC.Get\Pokec_Messenger\ver.beta\Pokec_<em>Messenger\WpfApplication1\MainWindow.xaml.cs:line 97<br>
       at System.Linq.Observable.&lt;>c</em>_DisplayClass389`1.&lt;>c_<em>DisplayClass38b.b</em>_388(TSource x)</p>
  </blockquote>