title: polymorphism for external package
body: <p>In my project I included an external package for the control AutoCompleteTextBox (<a href="https://wpfautocomplete.codeplex.com/" rel="nofollow noreferrer">https://wpfautocomplete.codeplex.com/</a>). </p>
  
  <p>I also have an on screen keyboard. </p>
  
  <p>Whenever the user clicks on a textbox, the keyboard assigns this keybord to a property itself has and each click on a number adds that number to the textbox. </p>
  
  <p>Some textbox must autocomplete and others must be the usual TextBox. </p>
  
  <p>The problem here is that AutoCompleteTextBox doesn't inherits from TextBox, therefore I cannot make a unique "assign TextBox" for the keyboard. But both controls share the property "Text", which is the only I need to use. </p>
  
  <pre><code>public partial class Keypad : UserControl
  {
      private AutoCompleteTextBox _controlAsignado; //this should be a generic class or an interface
      public Keypad() { }
      public void AsignarControl(AutoCompleteTextBox control)
      {
          _controlAsignado = control;
      }
      private void button_Click(object sender, RoutedEventArgs e)
      {
         Button button = sender as Button;
         switch (button.CommandParameter.ToString())
             {
             case "BACK":
                 if (_controlAsignado.Text.Length &gt; 0)
                              _controlAsignado.Text = _controlAsignado.Text.Remove(_controlAsignado.Text.Length - 1);
                 break;
             default:
                 _controlAsignado.Text += button.Content.ToString();
                 break;
             }
      }
  </code></pre>
  
  <p>}</p>
  
  <p>It would be awesome to have a "ITextBox" which both controls implement. </p>
  
  <p>I know I can solve this issue using reflection but I want an elegant solution. </p>
  
  <p><a href="https://i.stack.imgur.com/kuFSM.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/kuFSM.png" alt="Horas Maquina and Orden Servicio must be &quot;TextBox&quot;, the rest are AutoCompleteTextBox"></a></p>