title: MaxLength for AutoCompleteBox in Silverlight
body: <p>I use an AutoCompleteBox control in my project. Now I need to restrict the length of text a user can enter, e.g. by the maximum length 50 characters. For this case, TextBox has the MaxLength property, but AutoCompleteBox hasn't. Also, AutoCompleteBox doesn't expose TextBox's properties.</p>
  
  <p>I tried to resolve the issue in this way:</p>
  
  <pre><code>private void autoCompleteBox_TextChanged(object sender, RoutedEventArgs e)
  {
          AutoCompleteBox autoCompleteBox = sender as AutoCompleteBox;
          if (autoCompleteBox.Text.Length &gt; MaxCharLength)
          {
              autoCompleteBox.Text = autoCompleteBox.Text.Substring(0, MaxCharLength);
          }
  }
  </code></pre>
  
  <p>A big drawback of this method is that after setting the Text property, the text box caret is reset to the start position, and when a user go on typing, characters at the end are trimmed and the caret always go to the beginning.
  There are no methods exposed to control the caret (like the TextBox's Select method).</p>
  
  <p>Any ideas how can the maximum length be set for AutoCompleteBox?</p>