This question has already been answered:

In the textBox you need to make sure that when you enter the first letter was automatically large. That is, I write the last name with a small one, and the program corrects it for a large one. Please tell me how to do it

Reported as a duplicate by participants aleksandr barakin , PashaPash c # May 13 '17 at 19:42 .

A similar question was asked earlier and an answer has already been received. If the answers provided are not exhaustive, please ask a new question .

  • 2
    Didn't you ask almost the same question yesterday? - VladD

1 answer 1

If you are too lazy to connect xpression.Blend.Sdk then here is a simple but rather clumsy solution:

Markup

 <TextBox x:Name="textBox" HorizontalAlignment="Left" Height="23" Margin="155,102,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="186" TextChanged="textBox_TextChanged"/> 

TextChanged Handler

 public int i = 0; private void textBox_TextChanged(object sender, TextChangedEventArgs e) { i++; if (i == 1) { textBox.Text = textBox.Text[0].ToString().ToUpper(); } else { textBox.SelectionStart = textBox.Text.Length; } if (textBox.Text.Length ==0) { i = 0; } } 

When entering text, we consider i is 1 and the first character is output in the upper key, then we transfer the caret to the end of the text field and display the text as it is in the normal registry. When deleting the entire contents of the text field, reset i and enter the capital with a capital letter. Although of course for each field will have to create a separate variable to store the number of characters that is not gud.