locked
Windows 8 winRT - TextBox - Upper Case setting RRS feed

  • Question

  • I have a TextBox that I would like to set the Property to make every word automatically be Upper Case, but I cannot find this property in the winRT control.

    Any ideas?

    Thank you

    Monday, September 3, 2012 12:40 AM

Answers

  • Hi,

    There is no such property in textbox.

    Here is my solution:

     <StackPanel Background="{StaticResource ApplicationPageBackgroundThemeBrush}">
            <TextBox Name="tbox1" TextChanged="tbox1_TextChanged_1" />
        </StackPanel>

           private void tbox1_TextChanged_1(object sender, TextChangedEventArgs e)
            {
                this.tbox1.Text = this.tbox1.Text.ToUpper();
                this.tbox1.SelectionStart = this.tbox1.Text.Length;
            }

    Hope this helps

    Aaron Xue [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Proposed as answer by Dave SmitsMVP Monday, September 3, 2012 2:16 PM
    • Marked as answer by Aaron Xue Monday, September 24, 2012 9:34 AM
    Monday, September 3, 2012 8:26 AM

All replies

  • Hi,

    There is no such property in textbox.

    Here is my solution:

     <StackPanel Background="{StaticResource ApplicationPageBackgroundThemeBrush}">
            <TextBox Name="tbox1" TextChanged="tbox1_TextChanged_1" />
        </StackPanel>

           private void tbox1_TextChanged_1(object sender, TextChangedEventArgs e)
            {
                this.tbox1.Text = this.tbox1.Text.ToUpper();
                this.tbox1.SelectionStart = this.tbox1.Text.Length;
            }

    Hope this helps

    Aaron Xue [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Proposed as answer by Dave SmitsMVP Monday, September 3, 2012 2:16 PM
    • Marked as answer by Aaron Xue Monday, September 24, 2012 9:34 AM
    Monday, September 3, 2012 8:26 AM
  • Thank you for the confirmation and the sample code.
    Monday, September 3, 2012 1:53 PM
  • Well...I have to say, this is not a good solution. In my opinion, it's better to remind user that the text in Textbox has to be upper case rather than limiting user's input.

    Aaron Xue [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Monday, September 3, 2012 2:39 PM
  • I understand what you are saying. After I tried using the code, which works, in my original question it looks like I did not describe what I wanted to do better. I used the word Upper instead of Capitalize each word. I am currently trying to figure out if this can be done.

    For example if the user types 'world full contact karate' I would like it to automatically convert each word with the Capital letter like 'World Full Contact Karate'.

    Thank you.

    Monday, September 3, 2012 3:29 PM