Question

Is there a way to automatically capitalize all input thoughtout a WPF app?

Was it helpful?

Solution

You can case all input into TextBox controls with the following property:

CharacterCasing="Upper"

To apply to all TextBox controls in the entire application create a style for all TextBox controls:

<Style TargetType="{x:Type TextBox}">
    <Setter Property="CharacterCasing" Value="Upper"/>
</Style>

OTHER TIPS

I recommend creating a custom Textbox class and override an event to automatically capitalize the text. First, this depends on if you want the text to be capitalize as they type or after input is finished.

E.g. for after input is finished

public class AutoCapizalizeTextBox: TextBox
{
  public AutoCapitalizeTextBox()
  {
  }

  public AutoCapitlizeTextBox()
  {
  }

  protected override void OnLostFocus(EventArgs e)
  {
    this.Text = this.Text.ToUpper();

    base.OnLostFocus(e);
  }
}

I don't know if this'll help, it capitalizes all the first letters in the sentence.

http://www.mardymonkey.co.uk/blog/auto-capitalise-a-text-control-in-wpf/

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top