Hello @Shweta Goel , Welcome to Microsoft Q&A,
During the testing, Maxlength
property could work in touchscreen tablet device, please check if set the correct Maxlength value for the application. And if you want to delete text manually when the text length long than the Maxlength
, you could use the InputInjector
to delete it.
private void TextBox_TextChanging(TextBox sender, TextBoxTextChangingEventArgs args)
{
if (sender.Text.Length > 15)
{
InputInjector inputInjector = InputInjector.TryCreate();
var info = new InjectedInputKeyboardInfo();
info.VirtualKey = (ushort)(VirtualKey.Back);
inputInjector.InjectKeyboardInput(new[] { info });
}
}
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.