title: WPF - MVVM Textbox restrict to specific characters
body: <p>I am trying to make text box accept only specific characters.</p>
  
  <p>My TextBox is bound to the following:</p>
  
  <pre><code>    private string _CompanyID;
      public string CompanyID
      {
          get { return _CompanyID; }
          set
          {
              _CompanyID = UniversalHelpers.sReturnCorrectColumnName(value);
              OnPropertyChanged("CompanyID");
          }
      }
  </code></pre>
  
  <p>Where this is the function that is being called:</p>
  
  <pre><code>    public static string sReturnCorrectColumnName(string sInput)
      {
          if(!string.IsNullOrWhiteSpace(sInput))
              return Regex.Replace(sInput, @"[^a-zA-Z]", string.Empty).ToUpper();
          else
              return sInput;
      }
  </code></pre>
  
  <p>(I am allowing only a-z &amp; A-Z, nothing else).</p>
  
  <p>Finally my TextBox looks like this:</p>
  
  <pre><code>&lt;TextBox Text="{Binding ExcelBindings.CompanyID, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}" /&gt;
  </code></pre>
  
  <p>What I don't understand is, that user can still write anything he wants, even though my Mode is set to TwoWay. </p>
  
  <p>What am I doing wrong?</p>