I am using Maxlength property of textbox in WPF UWP Windows app. This property is working on laptop in both PC and tablet mode but it is not working on touchscreen tablet.
How to implement maxlength peroperty for touchscreen tablet. Please suggest.
I am using Maxlength property of textbox in WPF UWP Windows app. This property is working on laptop in both PC and tablet mode but it is not working on touchscreen tablet.
How to implement maxlength peroperty for touchscreen tablet. Please suggest.
Hello @ShwetaGoel-4677, 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.
5 people are following this question.