WPF Uppercase AutoComplete

Fri 10 August 2012 | in Blog

One of our clients wants uppercase characters in all of there inputs. Unfortunately System.Windows.Controls.AutoCompleteBox doesn't support the CharacterCasing option that is on a standard text box. My solution is to simply inherit from AutoCompleteBox and after the template has been applied grab the text box that is in the control and set it's CharacterCasing to uppercase.

public class UppercaseAutoComplete : AutoCompleteBox
{
    public override void OnApplyTemplate()
    {
        base.OnApplyTemplate();
        TextBox actualTextBox = this.Template.FindName("Text", this) as TextBox;
        actualTextBox.CharacterCasing = CharacterCasing.Upper;
    }
}

Comments !

blogroll

social