Click here to Skip to main content
15,885,107 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have used ToUpper to make capital letters in TextBox in UWP but getting issue of Cursor position in that Any other solution for it ?

What I have tried:

<pre>I have tried ToUpper, CharacterCasing and Typography.Capitals from which only ToUpper working other two are showing not accessible in textbox and for ToUpper i am facing problem for selectionStart posistion of cursor.

<TextBox x:Name="txt_rcpname_classic"  PlaceholderText="Recipient name" MaxLength="18" HorizontalAlignment="Left" Text="{Binding Path=To, Mode=TwoWay}" Grid.Column="1" Style="{StaticResource contentstyle}" TextChanging="txt_rcpname_classic_TextChanging" />

private void txt_rcpname_classic_TextChanging(TextBox sender, TextBoxTextChangingEventArgs args)
        {
            sender.Text = sender.Text.ToUpper();
            sender.SelectionStart = sender.Text.Length;
      }
Posted
Updated 19-Jan-19 22:44pm

Google search is your friend: uwp force textbox uppercase - Google Search[^]

Found two differend solutions in the first two search results using the above search:
* c# - Force textbox to be uppercase in UWP (Windows 10) - Stack Overflow[^]
* [C#][UWP]How can I make text input in a TextBox uppercase?[^]
 
Share this answer
 
private void TextBox_TextChanging(TextBox sender, TextBoxTextChangingEventArgs args)
{
    TextBox TBx = (TextBox)sender;
           
    int Pose = TBx.SelectionStart;
    TBx.Text = TBx.Text.ToUpper();
    TBx.SelectionStart = Pose;
}
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900